ZX BASIC:POKE

From BorielWiki
Jump to: navigation, search

Contents

POKE

Syntax

POKE <address>, <value>
POKE <type> <address>, <value>

Description

Stores the given (numeric) value at the specified memory address. If valueType is omitted, it is supposed to be ubyte (8 bit unsigned integer).

The value is converted to the given valueType and stored at the given Address. Type can be any numeric one (like float or integer).

Examples

It is possible to poke a decimal value (5 bytes) at a memory position:

POKE FLOAT 16384, PI

Traditionally, in Sinclair BASIC, to store a 16 bit value the programmer does something like this:

10 LET i = 16384
20 LET value = 65500
30 POKE i, value - 256 * INT(value / 256) : REM value MOD 256
40 POKE i + 1, INT(value / 256)

This can be done in a single sentence in ZX BASIC:

POKE UINTEGER 16384, 65500

It's faster and the recommended way.

Remarks

  • This statement is Sinclair BASIC compatible.
  • This statement extends the Sinclair BASIC one.
  • This statement also allows parenthesis and FreeBASIC syntax

See also

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox
Translate
Google AdSense