English
Language : 

NSB8 Datasheet, PDF (94/158 Pages) List of Unclassifed Manufacturers – BASIC interpreter for Z80 family
grifo®
ITALIAN TECHNOLOGY
10 REM More substring assignment.
20 DIM L$(13)
30 L$=”ABCDEFGHIJKLM’
40 PRINT L$
50 L$(5,9)=”12345”
60 PRINT L$
70 L$(5,9)=”abc”
80 PRINT L$
Here are the three output lines produced by the program:
ABCDEFGHIJKLM
ABCD12345JKLM
ABCDabc45JKLM
In the assignment of line 50, “12345” exactly fit the substring L$(5,9). However, in line 70, “abc”
was two characters short, so only the first three characters of the substring, characters 5 through 7,
were modified.
It is also possible to use the open ended substring form to specify a substring interval into which a
value is to be assigned. For example, L$(5) is taken to specify the same interval as L$(5,LEN(L$)).
where LEN(L$) stands for the current length of L$. In the substring assignment example above,
exactly the same results would have been obtained if the substring interval expressions in the string
assignment statements had been replaced by open ended substring expressions.
Assignment of the null string to any substring specified by regular or open ended substring notation
causes no change in the string.
MAXIMUM LENGTH AND CURRENT LENGTH
The maximum length of a string variable is the maximum number of characters which it can
hold. M$, dimensioned to 50, can hold up to 50 characters at once, but no more. On the other hand,
a string’s current length (as determined by the LEN function) is the number of characters which the
variable actually does contain at any one time. Thus, if M$ contains “CAT”, its current length is 3,
despite the fact that its maximum length is 50. As long as M$=”CAT”, BASIC statements and string
expressions may not access any character positions in M$ beyond the third. While M$=”CAT”, the
character positions beyond the third simply do not exist, and a reference such as M$(3,5) is
illegal. But, if M$ is changed to “STICK”, then its current length becomes 5, and M$(3,5) is
allowed. However, it is always incorrect to reference a character position beyond the maximum
length of the string. In this example of M$, the substring reference M$(40,60) will always be illegal,
since M$ can never grow larger than 50 characters in length, and therefore, the character positions
from 51 to 60 will never exist.
CHARACTER SET IN BASIC
Up to now, character has been used in its intuitive sense, as a digit, letter or punctuation character
which may be typed in by a user or printed on a terminal. In fact, the BASIC character set includes
invisible control characters and the many undefined characters which may be represented as byte (8
Page 82
NSB8
Rel. 5.10