User Tools

Site Tools


poke_write_to_memory_address_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== POKE (write to memory address) ====== Previous pageReturn to chapter overviewNext page

POKE(address,source)

blk2blue.jpg

POKE Writes data to a memory address.
address A numeric constant, variable, or expression (evaluated to a LONG) which specifies a memory address. This parameter should always use the ADDRESS procedure, to ensure the correct protected mode address is used.
source The label of a variable.

The POKE statement writes the contents of the source variable to the memory address at address. POKE writes as many bytes as are in the source variable.

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

Example:

MAddress         LONG

Source1          BYTE

Source2          SHORT

Source3          REAL

KeyboardFlag     BYTE

  CODE

  POKE(ADDRESS(MAddress),Source1)  !Write 1 byte to the memory location

  POKE(ADDRESS(MAddress),Source2)  !Write 2 bytes to the memory location

  POKE(ADDRESS(MAddress),Source3)  !Write 8 bytes to the memory location

  KeyboardFlag = BOR(KeyboardFlag,40h)   !turn on caps lock

  POKE(ADDRESS(00400017h),KeyboardFlag)  !and put it back

See Also:

PEEK

ADDRESS

poke_write_to_memory_address_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1