Statement: string – Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual

Page 79

Advertising
background image

Operating Functions

Chapter 5

5–42

Note that the line number printed out after execution of the STOP
statement, is the line number following the STOP statement, not the line
number that contains the STOP statement.

Mode: COMMAND and/or RUN
Type: CONTROL

The STRING [expr], [expr] statement allocates memory for strings.
Initially, no memory is allocated for strings. If you attempt to define a
string with a statement such as LET $(1)“HELLO” before memory is
allocated for strings, a MEMORY ALLOCATION ERROR is generated.
The first expression in the STRING [expr],[expr] statement is the total
number of bytes you want to allocate for string storage. The second
expression gives the maximum number of bytes in each string. These two
numbers determine the total number of defined string variables.

The BASIC Module requires one additional byte for each string, plus one
additional byte overall. The additional character for each string is allocated
for the carriage return character that terminates the string. This means that
the statement STRING 100,10 allocates enough memory for 9 string
variables, ranging from $(0) to $(8) and all of the 100 allocated bytes are
used. Note that $(0) is a valid string in the BASIC Module. Refer to the
following Section 5.10 titled, “Description of String Operators” for further
discussion of strings and example programs for string memory allocation.

Important: After memory is allocated for string storage, commands (e.g.
NEW) and statements (e.g. CLEAR) cannot “de-allocate” this memory.
Cycling power also cannot de-allocate this memory unless battery backup
is disabled. You can de-allocate memory by executing a STRING 0,0
statement. STRING 0,0 allocates no memory to string variables.

Important: The BASIC Module executes the equivalent of a CLEAR
statement every time the STRING [expr],[expr] statement executes. This is
necessary because string variables and numeric variables occupy the same
external memory space. After the STRING statement executes, all
variables are “wiped-out”. Because of this, you should perform string
memory allocation early in a program (during the first statement if
possible). If you re-allocate string memory you destroy all defined
variables.

5.4.30
Statement: STOP
(continued)

5.4.31
Statement: STRING

Advertising