Rockwell-automation 1746-BAS BASIC LANGUAGE User Manual Page 35

  • Download
  • Add to my manuals
  • Print
  • Page
    / 280
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 34
Publication 1746-RM001A-US-P
Expressions and Operators 3-13
When you use the ASC operator as shown above, the $([expr]) denotes what string
is accessed. The expression after the comma selects an individual character in the
string. In the above 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.
>NEW
>1 REM EXAMPLE PROGRAM
>5 STRING 1000,40
>10 $(1)=“ABCDEFGHIKJL”
>20FORX=1TO12
>30 PRINT ASC($(1),X),
>40 NEXT X
>50 END
READY
>RUN
65 66 67 68 69 70 71 72 73 75 74 76
READY
>
The numbers printed in the previous example represent the ASCII characters A
through L.
You can also use the ASC operator to change individual characters in a defined
string.
In general, the ASC operator lets you manipulate individual characters in a string.
A simple program can determine if two strings are identical.
>NEW
>1 REM EXAMPLE PROGRAM
>5 STRING 1000,40
>10 $(1) = “ABCDEFGHIJKL”
>20 PRINT $(1)
>30 ASC($(1),1) = 75 : REM DECIMAL EQUIVALENT OF K
>40 PRINT $(1)
>50 ASC($(1),2) = ASC($(1),3)
>60 PRINT $(1)
READY
>RUN
ABCDEFGHIJKL
KBCDEFGHIJKL
KCCDEFGHIJKL
READY
>
Page view 34
1 2 ... 30 31 32 33 34 35 36 37 38 39 40 ... 279 280

Comments to this Manuals

No comments