String operators, String operators -12, Asc([expr]) – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 34

Advertising
background image

Publication 1746-RM001A-US-P

3-12 Expressions and Operators

String Operators

Two operators in the module can manipulate STRINGS. These operators are ASC(
) and CHR( ).

ASC([expr])

Use the ASC operator to return the integer value of the ASCII character placed in
the parentheses.

>1 REM EXAMPLE PROGRAM

>10 PRINT ASC(a)

>20 PRINT ASC(A)

READY

>RUN

65

65

READY

>

The decimal representation for the ASCII character A is 65. The decimal
representation for the ASCII character a is 97. However, the module capitalizes all
ASCII characters not contained within quotation marks. Similarly, special ASCII
characters whose decimal value is greater than 127 should not be used.

In addition, you can evaluate individual characters in a defined ASCII string with
the ASC operator.

>1

REM EXAMPLE PROGRAM

>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

>

Advertising