Basic programming guide – Remote Processing BASIC for the CX-10 Modbus User Manual
Page 74

BASIC PROGRAMMING GUIDE
2-65
STRING
Syntax:
STRING total bytes,string length
Where: total bytes = total number of bytes in memory to allocate
string length = maximum number of bytes in a string
Function:
Allocate memory for strings
Mode:
Command, run
Use:
STRING 56,10 : REM Allocate memory for 5 10-byte strings
DESCRIPTION
Prior to using strings, you must use STRING to allocate memory for them. The STRING argument values are
computed by this equation:
total bytes = ((string length + 1) * number_of_strings) +1
The only way to recover string memory is with a "STRING 0,0" instruction. String memory is reclaimed and
then reallocated each time you use the STRING operator. Strings are terminated with a carriage return (0DH
or 13) which is the additional byte added to your bytes per string expr.
WARNING:
STRING causes BASIC-52 to execute the equivalent of a CLEAR instruction since string and numeric
variables occupy the same memory space. In other words, the STRING instruction clears all variables,
interrupts and stacks. Allocate string memory early in your program and don't reallocate it unless you can
accept the loss of all variables.
RELATED
ASC, CHR
ERRORS
MEMORY ALLOCATION
Memory not allocated for strings
C-STACK
STRING used in a subroutine, clearing the stack.
EXAMPLES
10
STRING 1000,40
20
$(0) = "Up to 40 characters in this string"
.
.
100
$(2) = COM$(1)