Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual

Page 113

Advertising
background image

Operating Functions

Chapter 5

5–76

It is important to note that since the carriage return character is the string
terminator, you cannot use it within a string as one of its characters. If the
high bit is set in a carriage return character (use 141 instead of 13 as the
decimal value of the carriage return character) the BASIC Module does not
recognize it as the end of string character and passes it to the output device.
Most devices use a seven bit ASCII code, ignore the top bit and treat the
141 as a normal carriage return.

Important: All undefined characters of a string (i.e. characters following
CR) are nulls. If data is input to a string using the ASC($(X),I) command,
you must be sure the string is (CR) terminated properly. You can initialize
the string or add a (CR) to terminate the string.

Example:

u10 STRING 100,10
u20 FOR I=1 TO 5
u30 ASC($(0),I)=65
u40 NEXT I
u50 PRINT $(0)
uRUN
AAAAA

The string is stored in memory without a (CR) terminator. Be sure to insert
a (CR) (0DH) into the last position of the string if using the above method.

Example:

u10 STRING 100,10
u20 FOR I=1 TO 5
u30 ASC ($(0),I) = 65
u40 NEXT I
u45 ASC($(0),6)=0DH
u50 PRINT $(0)
or

u10 STRING 100,10
u15 $(0))=“

u20 FOR 1 TO 5
u30 ASC ($(0),I) = 65
u40 NEXT I
u50 PRINT $(0)

The following three programs allow you to determine how much string
space to allocate when you know two of three variables associated with the
strings:

number of characters in the longest string.

number of string variables.

amount of memory to allocate for strings.

5.10.3
String Support Calls
(continued)

Advertising