Page 23 of 62
SBasic User's Manual SBasic Version 2.7 Page 23
Printed: December 5, 1999
COPY statement
SBasic provides the COPY statement, used to move data from one memory
area to another. This proves very handy when you need to initialize a
large array. Format of the COPY statement is:
copy from, to, count
where FROM is the address of the data block, TO is the address of the
destination area, and COUNT is the number of BYTES (not variables) to
move.
For example, assume you need to initialize the array FOO with a table
of data, already existing in a block of DATA statements. You would
use statements similar to:
declare foo(10)
table:
data $1234, $5678, $1, $2, $3, $4
data $5, $6, $7, $8
copy addr(table), addr(foo), 20
This code uses the ADDR() function to locate the addresses of the
TABLE data block and the FOO array, then moves 20 bytes of data from
the table to the array.
Note that COPY cannot be used to move data into an area of memory that
overlaps the source area. Should you need to perform this operation,
use two COPY statements, first to move the data into an intermediate
area, then to move it into the final destination area.