User Tools

Site Tools


peek_read_memory_address_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== PEEK (read memory address) ====== Previous pageReturn to chapter overviewNext page

PEEK(address,destination)

blk2blue.jpg

PEEK Reads data from a memory address.
Address A numeric constant, variable, or expression (evaluated to a LONG) that specifies a memory address. This parameter should always use the ADDRESS procedure, to ensure the correct address is used.
destination The label of a variable to receive the contents of the memory location.

The PEEK statement reads the memory address specified by address and copies the data found there into the destination variable. PEEK reads as many bytes as are required to fill the destination variable.

It is easily possible to create a General Protection Fault (GPF) if you PEEK at an incorrect address, so great care should be taken when using PEEK. There are usually Windows API procedures that will do whatever you require of PEEK and these should be used in preference to PEEK.

Example:

MemAddress       LONG

Dest1            BYTE

Dest2            SHORT

Dest3            REAL

KeyboardFlag     BYTE

 CODE

  PEEK(ADDRESS(MemAddress),Dest1)      !Read 1 byte

  PEEK(ADDRESS(MemAddress),Dest2)      !Read 2 bytes

  PEEK(ADDRESS(MemAddress),Dest3)      !Read 8 bytes

See Also:

POKE

ADDRESS

peek_read_memory_address_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)