English
Language : 

NSB8 Datasheet, PDF (91/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
ITALIAN TECHNOLOGY
grifo®
(current length = 0).
Immediately after being dimensioned, a string is initialized to contain all blanks. Thus, if A$ is
dimensioned to be 26 characters long, it initially contains a string of 26 blanks.
SUBSTRINGS
The programmer can access parts of a string, smaller segments consisting of one or more consecutive
characters from within the string. Such a segment is called a substring.
Substrings of string variables are represented by substring notation: adding a substring interval, in
parentheses, to the variable name. For example, assume that A$ holds the string value
“ABCDE” (unless otherwise stated, this will be the permanent value of A$ throughout the
discussion). To represent its substring “CD”, you would write A$ (3,4), which specifies a substring
consisting of the 3rd through the 4th characters of A$. A$ (3,3) would yeld the value of “C”, and A$
(2,5) would represent “BCDE”.
Either or both of the numeric values in a substring interval may be represented by any numeric
expression, as long as each expression evaluates to a value greater than or equal to 1 and less than
or equal to the current number of characters in the string. Whenever any of the numeric values in a
substring interval are non integer, BASIC ignores the fractional parts. Thus, 5.6 is taken as 5, and 1.23
is taken as 1 If A=3 and B=4 then A$ (A,B) would be the same as A$ (3,4), or “CD”. If B is more
than 5, or A is less than 1, A$ (A,B) would not be allowed, causing an OUT OF BOUNDS
ERROR. This error will also occur if the value of the first expression is greater than the value of the
second. Therefore, a backwards substring such as A$ (4,2) is illegal.
THE OPEN ENDED SUBSTRING
A special form of substring notation is used to reference a substring consisting of all the characters
from a given starting position in the string through its end. open ended substring notation uses only
one numeric expression, which specifies the starting position within the string, and which must be
greater than or equal to 1 and less than or equal to the length of the original string. For example, A$(3)
stands for “CDE”. Note that the value of A$ as a whole is the same as the value of the open ended
substring A$(1). A$(5) and A$(5,5) are the same as well, since the 5th character is the last character
in A$. Use of open ended substring notation eliminates the need, in certain situations, to know the
current length of the original string.
STRING CONCATENATION
The concatenation operation may be performed on strings, symbolized by the plus operator (+). This
is not to be confused with numeric addition. Instead, concatenation is the joining of two strings, front
to back, rather like coupling railroad cars tigether. For example, “CAR”+”LOAD” represents the
same value as “CARLOAD”. Any string value may be concatenated with any other string value to
yeld a third value which consists of the two linked together. A$(2,3)+A$(2) yelds the value
“BCBCDE” (remember that A$ has held “ABCDE” throughout this discussion). Concatenation
operations can be chained, such as in
A$(1,1)+A$(3,3)+A$(3,3)+A$(5)+A$(4)+” MEANS YELD”
which gives the value “ACCEDE MEANS YELD”.
NSB8
Rel. 5.10
Page 79