POKE statement

Purpose:

Stores a block of bytes to a specified memory location.

Syntax:

POKE(Destination, Source AS STRING, ByteBlockSize AS INTEGER)

Parameters:

  • Data type: Identifier
    Destination The memory address to copy Source.
  • Data type: STRING
    Source A block of bytes to copy to memory.
  • Data type: INTEGER
    ByteBlockSize The size of Source block of bytes.

Example:

This example uses PEEK$ and POKE in BCX to quickly copy one array to another, which is much faster than using a FOR ... NEXT loop to move each element.

DIM a![10]
DIM b![10]

FOR INTEGER i = 0 TO 9
  a![i] = i + 0.1
NEXT

POKE(b,PEEK$(a,SIZEOF(a)),SIZEOF(a))

FOR INTEGER i = 0 TO 9
  PRINT "b![", i, "] = ", b![i]
  PRINT "now contains the same data as is in"
  PRINT "a![", i, "] = ", a![i]
  ?
NEXT

Result:

b![0] =  0.1
now contains the same data as is in
a![0] =  0.1

b![1] =  1.1
now contains the same data as is in
a![1] =  1.1

b![2] =  2.1
now contains the same data as is in
a![2] =  2.1

b![3] =  3.1
now contains the same data as is in
a![3] =  3.1

b![4] =  4.1
now contains the same data as is in
a![4] =  4.1

b![5] =  5.1
now contains the same data as is in
a![5] =  5.1

b![6] =  6.1
now contains the same data as is in
a![6] =  6.1

b![7] =  7.1
now contains the same data as is in
a![7] =  7.1

b![8] =  8.1
now contains the same data as is in
a![8] =  8.1

b![9] =  9.1
now contains the same data as is in
a![9] =  9.1