English
Language : 

NSB8 Datasheet, PDF (92/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
grifo®
ITALIAN TECHNOLOGY
STRING FUNCTIONS
BASIC includes certain built in functions which return useful string values. It is also possible to
define single line and multiple line user functions which return string values. See section FUNCTIONS
for more detailed information.
STRING EXPRESSIONS
A string expression is a string variable, substring, string function, or a quoted string literal. The
concatenation of two string values is also a string expression. Long, involved compound expressions
may be formed by combining one or more of the elements mentioned above. For example:
A$
F$+”,2”
A$(1,X)+CHR$(97)+A$+”GO FOR BROKE”+FNS$(25)
The built in string functions (e.g. CHR$) and the user defined string functions (e.g. FNS$) will be
discussed later.
STRING COMPARISONS
String values may be compared using the comparison operators = , > , < , <= , >= , and <> . BASIC
compares string values using the following rules:
1) Two string values are equal only if they have the same number of characters, and have
matching characters in each character position.
2) Strings are compared character by character, left to right, until a difference occurs or one of
the strings ends.
3) If a difference exists, and the ascii value of the first different character in the first string is less
than that of the corresponding character in the second string, then the first string is less than
the second string. If the character in the first string is greater than its counterpart in the second
string, then the first string is greater than the second.
4) If one of the strings ends before a difference is found, the shorter string is considered to be
less than the larger one.
5) As a consequence of rule #4, the null string is always less than a non null string.
When using strings composed solely of alphabetic characters of the same case (either upper or lower,
but not both), this scheme corresponds to comparsion by dictionary order, where an entry is
considered to be less than another if it comes before the other in the dictionary, and greater than the
other if it comes after. Thus bird is less than (comes before) tree, and zero is greater than (comes after)
aardvark. The difference between string comparisons in BASIC and regular word comparison by
alphabetic order lies solely in the fact that the ascii character set, used to define alphabetic order in
BASIC, has 128 letters as opposed to our usual 26.
To give you a better idea of this expanded alphabetic order, here are some samples of string
comparisons; use the five rules above and a standard table of ascii codes to check the following
examples:
Page 80
NSB8
Rel. 5.10