bas7advr.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 Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
The PEEK function returns the byte stored at a specified memory
location. The returned value is an integer between 0 and 255, inclusive.
 
PEEK(address)
 
Usage Notes
    ■ 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.
    ■ 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:
 
        ' Set the current segment address to the address of a$.
        DEF SEG = SSEG(a$)
        ' Determine the string's location within the segment.
        StringOffset = SADD(a$)
        ' Return the byte stored at this location.
        PEEK(StringOffset)
 
Important
    ■ Direct string manipulation with PEEK should be used cautiously,
      because BASIC moves string locations during runtime. The DEF SEG
      statement should be executed immediately before using the PEEK
      function.
 
PEEK and Expanded-Memory Arrays
    ■ Do not use PEEK to return a byte from an expanded memory array. If
      you start QBX 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
    ■ If you want to use PEEK to return a byte from an array, first start
      QBX without the /Ea switch. (Without the /Ea switch, no arrays are
      stored in expanded memory.)
    ■ For more information on using expanded memory, see
      Using Expanded Memory.
 
Programming With OS/2 Protected Mode
    ■ Any address referred to by PEEK must be readable. If PEEK refers
      to an address for which your process does not have read permission,
      the operating system may generate a protection exception, or BASIC
      may generate the error message, "Permission denied."