advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
PEEK Function, POKE Statement Details
  Summary  Details  Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
 PEEK(address)
 POKE address, byte%
 
 Usage Notes
   ■ Warning: Use POKE carefully. If used incorrectly, it can cause Visual
     Basic or the operating system to fail.
 
   ■ Direct string manipulation with PEEK should be used cautiously, because
     Visual Basic moves string locations during run time. The DEF SEG
     statement should be executed immediately before using the PEEK function.
     See: DEF SEG Statement
 
   ■ Visual Basic moves string locations during run time. Therefore, the
     DEF SEG statement must be executed immediately before using the POKE
     statement.
 
   ■ If address is a single- or double-precision floating-point value or a
     long integer, it is converted to a 2-byte integer.
 
   ■ The PEEK function complements the POKE statement and vice versa.
 
   ■ When using PEEK to return a byte from a far-string array, use the
     SSEG and SADD functions to obtain the current segment and offset.
     For example:
 
         DEF SEG = SSEG(a$)            ' Set the current segment address
                                       ' to the address of a$
         StringOffset = SADD(a$)       ' Determine the string's location
                                       ' within the segment
         PEEK(StringOffset)            ' Return the byte stored at this
                                       ' location
 
   ■ Before using POKE to directly manipulate data stored in far memory,
     use the DEF SEG statement and the SSEG function to set the current
     segment address. For example:
 
         DEF SEG = SSEG(a$)            ' Set the current segment address
                                       ' to the address of a$
         Offset1 = SADD(a$)            ' Determine the string's location
                                       ' within the segment
         POKE Offset1, PEEK(Offset2)   ' Write the byte stored in:
 
   ■ Do not use PEEK or POKE with an expanded-memory array. If you start
     Visual Basic (VBDOS.EXE) with the /Ea switch, any of these arrays may be
     stored in expanded memory:
     • Numeric arrays < 16K in size
     • Fixed-length string arrays < 16K in size
     • User-defined type arrays < 16K in size
     See: VBDOS Command-Line Options
 
   ■ If you want to use PEEK or POKE with an array, first start Visual Basic
     (VBDOS.EXE) without the /Ea switch. Note: Without the /Ea switch, no
     arrays are stored in expanded memory.