POKE$$ statement

Purpose | Store a byte or sequence of bytes at a specified memory location.
Syntax | POKE [DataType,] Address???, DataValue [, DataValue...] POKE$ [STRINGZ,] Address???, StringExpr POKE$$ [WSTRINGZ,] Address???, StringExpr

Remarks

The POKE statements and complementary PEEK functions are low-level methods of accessing individual bytes in memory. The data is stored to memory starting at the specified 32-bit address.

In its classic form, the POKE statement stores a single byte (8 bits) whose value ranges from 0 to 255. In its enhanced form, POKE provides the functionality of a dynamic pointer: the DataType parameter specifies the data type and hence the size of the target data to write to the target memory address. DataType can be any one of BYTE, WORD, DWORD, INTEGER, LONG, QUAD, SINGLE, DOUBLE, EXT, CUR, CUX. If a DataType is not specified, BYTE is assumed. If you specify more than one DataValue, they are stored in successive memory locations.

POKE$ stores the bytes of StringExpr in consecutive bytes of memory. If STRINGZ (or ASCIIZ) is specified, POKE$ writes successive characters to memory, up to the specified size, until a terminating $NUL byte is found in the source string. If no $NUL is found in the string, one is automatically appended. It is the programmer's responsibility to ensure that POKE$ does not overrun the target memory area to avoid data corruption or protection faults.

POKE$$ stores the characters of StringExpr as consecutive 2-byte words of memory. If WSTRINGZ is specified, POKE$$ writes successive wide characters, up to the specified size, until a terminating $NUL is found in the source string. If no $NUL is found in the string, one is automatically added. It is the programmer's responsibility to ensure that POKE$$ does not overrun the target memory area to avoid data corruption or protection faults.

Contrarary to intuitive notions, PEEK and POKE execute at the same high performance levels as pointer variables. They offer an excellent alternative to pointers in many situations.

Address??? | A valid 32-bit memory address specifying the location in memory where data storage should begin.
Datavalue | The data value to be stored at Address???.
StringExpr | A string constant, literal or expression that specifies the sequence of characters to be stored in memory, starting at by Address???.
Restrictions | If POKE attempts to access memory that is not allocated to the application, Windows will generate a General Protection Fault (GPF) and terminate the application. GPFs cannot be trapped.
See also | GLOBALMEM ALLOC, MEMORY, PEEK, STRPTR, VARPTR