118
The
VIC
20
User
Guide
Concatenating
Strings
Strings can contain alphabetic or numeric characters or combinations
of
these. When handling strings, it may be useful to link shorter strings
end-to-end in a chain-like fashion to create one large string. This linking
process, as you may recall,
is
called concatenation.
String 1
String 2
String 3
String 4
I String 1
String 2
String 3
Suppose, for example, you want to create one large string, Z$, contain-
ing the alphabet A through
Z.
To do this, you can link the last character
of
A$, shown below, to the first character
of
J$, and the last character of J$ to
the first character of S$.
A$
J$
S$
fA
1
sic
1 D 0
FIG
1 H 1
;n
1 Kid; Q 01 P 1 Q 1
RUS
1 T 1 u 1
v}W
1 x 1 v 1 zl
Z$IAISICIDIEIFIGIHlt
IJ
IKILIMINlol
plQIRISITlulvlwlxlvlzl
When a plus sign appears between two numeric expressions, it adds the
values
of
the expressions. However, the plus sign will concatenate strings
when string variables appear on either side of it.
The same
is
not true
of
the minus sign. Strings cannot be separated
or
"de-concatenated" in the same way they are concatenated; they cannot be
"subtracted" the way they are "added."
For
instance,
to
create string X$, containing the contents
of
J$ and
S$
from our original strings A$, J$, S$, and Z$, it would be incorrect to type