String data types, String data types tip – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 102

Advertising
background image

Chapter
Data Types

8

8 -2

A string is a character or group of characters stored in memory.
Usually, the characters stored in a string make up a word or a sentence.
Strings allow you to use characters instead of numbers. Strings are shown
as

$(

expr).

The BASIC module uses single-dimension string variables, $(expr).
The dimension of a string variable (the expr value) ranges from 0 to 254.
This means you can define and manipulate 255 different strings in the
BASIC module. Initially, memory is not allocated for strings.
You allocate memory with the STRING statement (page 11 -37).
Declare and manipulate strings through the $ type declaration character
(page 9 -2).

You can only use one STRING statement in your program to allocate
memory for all the strings you want to use in your program.
When allocating memory for strings remember that the STRING statement
itself has one overhead byte. As well, BASIC uses one overhead byte per
string declared within the STRING statement.

For example,

STRING 106,20

allocates 106 bytes for string memory.

The 106 bytes of string memory includes five 20-byte strings (100 bytes),
five overhead bytes (1 per string) and one additional byte (for the STRING
statement itself). The BASIC module automatically numbers these fives
strings as $(0), $(1), $(2), $(3), and $(4).

In the BASIC module you can define strings with the:

LET statement (page 11 -19)
INPUT statement (page 11 -17)
ASC operator (page 9 -14)

Remember define strings first, unless you are executing a CALL 77 (page
13 -6). Then, execute CALL 77 first and define your strings immediately
after.

String Data Types

Tip

Advertising