%memcpy() function

The %memcpy() function copies the number of characters specified by number from memory area s2 into s1.

Syntax

var = (char*)%memcpy(s1, s2, length)

Parameter(s)

var Pointer to s1.
s1 Can be a FlashBASIC string or a pointer to a character. If s1 is a D3 string, the value returned by this function has no meaning.
s2 Can be a FlashBASIC string or a pointer to a character.
length Number of bytes to copy.
Note: If the string contains a segment mark (x’ff’), the data is truncated.

Example(s)

* Read 1024 bytes from device
* and copy them in a D3 buffer
precision 0
char buffer[1024]
p=(char*)%malloc(1024)
n=%read(fd, (char*)p, 1024)
%memcpy(buffer, p+32, n-32)

In this example, note the operation on pointers, allowed because of the statement precision 0. This allows reading data from a device, and copy only the portion after a fixed size header (32 bytes in this example).