EasyManua.ls Logo

Campbell CR850 - Extracting String Characters; Inserting String Characters; String Use of ASCII; ANSII Codes; Table 41. Extracting String Characters

Campbell CR850
566 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Section 7. Installation
240
Some smart sensors send strings containing NULL characters. To manipulate a
string that has NULL characters within it (in addition to being terminated with
another NULL), use MoveBytes() instruction.
7.8.13.4 Inserting String Characters
CRBasicExample48. InsertingStringCharacters
Objective:
Use MoveBytes() to change "123456789" to "123A56789"
Given:
StringVar(7) = "123456789" 'Result is
"123456789"
Try (does not work):
StringVar(7,1,4) = "A" 'Result is
"123A<NULL>56789"
Instead, use:
StringVar(7) = MoveBytes(Strings(7,1,4),0,"A",0,1) 'Result is
"123A56789"
7.8.13.5 Extracting String Characters
A specific character in the string can be accessed by using the "dimensional"
syntax; that is, when the third dimension of a string is specified, the third
dimension is the character position.
Table 41. Extracting String Characters
Expression Comments Result
StringVar(3) = "Go Jazz"
Loads string into variable
StringVar(3) = "Go Jazz"
StringVar(4) = StringVar(3,1,4)
Extracts single character
StringVar(4) = "J"
7.8.13.6 String Use of ASCII / ANSII Codes
Table 42. Use of ASCII / ANSII Codes Examples
Expression Comments Result
LongVar (7) = ASCII("#")
35
LongVar (8) = ASCII("*")
42
LongVar (9) = "#"
Cannot be converted to Long with
NULL
NAN
LongVar (1) = "#"-""
Can be converted to Long without
NULL
35

Table of Contents

Related product manuals