Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
String Operators
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
String Operators
■ A string expression consists of string constants, string variables, and
other string expressions combined by string operators. There are two
classes of string operations: concatenation and string comparison.
■ String comparisons can be used to test string values or to alphabetize
strings. All string constants used in comparison expressions must be
enclosed in quotation marks ("").
■ The act of combining two strings is called concatenation. The plus symbol
(+) is the concatenation operator for strings. For example, the following
code combines the string variables A$ and B$ to produce the value
FILENAME:
A$ = "FILE": B$ = "NAME"
PRINT A$ + B$
PRINT "NEW " + A$ + B$
where the output is:
FILENAME
NEW FILENAME
■ Strings can be compared using the same relational operators used with
numbers: <>, =, <, >, <=, and >=.
■ String comparisons are made by taking corresponding characters from each
string and comparing their ASCII codes:
• If the ASCII codes are the same for all the characters in both strings,
the strings are equal.
• If the ASCII codes differ, the lower code number precedes the higher.
• If the end of one string is reached during string comparison, the
shorter string is smaller if they are equal up to that point.
See: ◄ASCII Character Codes►
■ Leading and trailing blanks are significant. For example, the following
are true string expressions:
"AA" < "AB"
"FILENAME" = "FILE"+"NAME"
"X&" > "X#"
"CL " > "CL"
"kg" > "KG"
"SMYTH" < "SMYTHE"
B$ < "9/12/78" ' Where B$ = "8/12/85"
See: ◄Expressions and Operators Summary► ◄String Operations►