String operators – Rockwell Automation 1771-DB BASIC MODULE User Manual
Page 124

Chapter
Expressions, Variables and Operators
9
9 -14
Two operators in the BASIC module can manipulate strings.
These operators are ASC and CHR.
ASC
Use the ASC operator to return the integer value of the ASCII character
placed in the parentheses.
The BASIC module capitalizes all ASCII characters. The decimal
representation for the ASCII character “A” is 65. The decimal
representation for the ASCII character “a” is 97. However the BASIC
module prints 65 for both characters.
>1 REM EXAMPLE PROGRAM
>10 PRINT ASC(a)
>20 PRINT ASC(A)
READY
>RUN
65
65
READY
>
Do not use special ASCII characters with a decimal value greater than 127.
In addition, you can evaluate individual characters in a defined ASCII
string with the ASC operator. When you use the ASC operator, the $(expr)
denotes what string you want to access. The expression after the comma
selects an individual character in the string. In this example, the first
character in the string is selected. The decimal representation for the
ASCII character T is 84. String character position 0 is invalid.
>5 STRING 1000,40
>10 $(1) =“THIS IS A STRING”
>20 PRINT $(1)
>30 PRINT ASC($(1),1)
>40 END
READY
>RUN
THIS IS A STRING
84
READY
>
String Operators