39
4.4 COMMANDS FOR STRING PROCESSING
This section describes BASIC commands used to manipulate sequences of ASCII
characters known as strings. In CipherLab BASIC, strings are always variable length,
from null to a maximum of 250.
Two strings can be combined with the plus operator “+”. The string following the plus
operator is appended to the string preceding the plus operator. For example,
…
Data$ = DATE$ + TIME$ + EmployeeID$
SAVE_TRANSACTION(Data$)
…
Two strings can be compared with the relational operators, see section 3.3.3.
A single character is greater than another character if its ASCII value is greater. For
example, the ASCII value of the letter “B” is greater than the ASCII value of the letter
“A”, so the expression “B” > “A” is true.
When comparing two strings, BASIC looks at the ASCII values of corresponding
characters. The first character where the two strings differ determines the alphabetical
order of the strings. For example, the strings “aaabaa” and “aaaaaaaa” are the same up
to the fourth character in each, “b” and “a”. Since the ASCII value of “b” is larger than
that of “a”, the expression “aaabaa” > “aaaaaaaa” is true.
If there is no difference between the corresponding characters of two strings and they
are the same length, then the two strings are equal. If there is no difference between the
corresponding characters of two strings, but one of the strings is longer, the longer string
is greater than the shorter string. For example, “abc” = “abc” and “aaaaaaaa” > “aaaaa”
are both true expressions.
Leading and trailing blank spaces are significant in comparing strings. For example, the
string “ abc” is less than the string “abc” since a blank space is less than an “a”; on the
other hand, the string “abc ” is greater than the string “abc”.