Section 7. Installation
Table 46.
String Operators
Operator
Description
&
Concatenates strings. Forces numeric values to strings before
concatenation.
Example
1 & 2 & 3 & "a" & 5 & 6 & 7 = "123a567"
+
Adds numeric values until a string is encountered. When a string is
encountered, it is appended to the sum of the numeric values. Subsequent
numeric values are appended as strings.
Example:
1 + 2 + 3 + "a" + 5 + 6 + 7 = "6a567"
-
"Subtracts" NULL ("") from the end of ASCII characters for conversion to
an ASCII code (LONG data type).
Example:
"a" - "" = 97
ASCII codes of the first characters in each string are compared. If the
difference between the codes is zero, codes for the next characters are
compared. When unequal codes or NULL are encountered (NULL
terminates all strings), the difference between the last compared ASCII
codes is returned.
Examples:
Note
— ASCII code for a = 97, b = 98, c = 99, d = 100, e = 101, and all
strings end with NULL.
Difference between
NULL
and
NULL
"abc" - "abc" = 0
Difference between
e
and
c
"abe" - "abc" = 2
Difference between
c
and
b
"ace" - "abe" = 1
Difference between
d
and
NULL
"abcd" - "abc" = 100
<
,
>
,
<>
,
<=
,
>=
,
=
ASCII codes of the first characters in each string are compared. If the
difference between the codes is zero, codes for the next characters are
compared. When unequal codes or NULL are encountered (NULL
terminates all strings), the requested comparison is made. If the comparison
is true,
-1
or
True
is returned. If false,
0
or
False
is returned.
Examples:
Expression
Result
x = "abc" = "abc"
x = -1 or True
x = "abe" = "abc"
x = 0 or False
x = "ace" > "abe"
x = -1 or True
7.9.19.2 String Concatenation
Concatenation is the building of strings from other strings ("abc123"), characters
("a" or
chr()
), numbers, or variables. The table
String Concatenation Examples
(p.
lists some expressions and expected results. CRBasic example
Concatenation
of Numbers and Strings
(p. 284)
demonstrates several concatenation examples.
When non-string values are concatenated with strings, once a string is
encountered, all subsequent operands will first be converted to a string before the
283
Summary of Contents for CR1000
Page 2: ......
Page 4: ......
Page 6: ......
Page 32: ......
Page 36: ......
Page 38: ......
Page 40: ......
Page 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Page 96: ......
Page 98: ...98 ...
Page 302: ......
Page 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Page 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Page 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Page 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Page 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Page 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Page 478: ......
Page 506: ......
Page 536: ......
Page 636: ......
Page 642: ......
Page 644: ......
Page 676: ......
Page 677: ......