Apple ii Battery Charger User Manual


 
ROCKW
ROCKWE
ROCKWEL
ROCKWELL
ROCKWELL R
ROCKWELL R6
ROCKWELL R65
ROCKWELL R650
ROCKWELL R6500
Since A$ has 14 characters this loop will be executed with N=1,2,3,...,13,14. The first time
through only the first character will be printed, the second time the first two characters will be
printed, etc.
RIGHT$ FUNCTION
Another string function, called "RIGHT$," returns the right N characters from a string expression.
Try substituting "RIGHT$" for "LEFT$" in the previous example and see what happens.
MID$ FUNCTION
There is also a string function which allows us to take characters from the middle of a string. Try
the following:
FOR N=1 TO LEN(A$):PRINT MID$(A$,N):NEXT N
ROCKWELL R6500
OCKWELL R6500
CKWELL R6500
KWELL R6500
WELL R6500
ELL R6500
LL R6500
L R6500
R6500
R6500
6500
500
00
0
"MID$" returns a string starting at the Nth position of A$ so the end (last character) of A$. The
first position of the string is position 1 and the last possible position of a string is position 255.
Very often it is desirable to extract only the Nth character from a string. This can be done by
calling MID$ with three arguments. The third argument specifies the number of characters to
return.
For example:
FOR N=1 TO LEN(A$):PRINT MID$(A$,N,1),MID$(A$,N,2):NEXT N
R RO
O OC
C CK
K KW
W WE
E EL
L LL
L L
R
R R6
6 65
5 50
0 00
0 0
CONCATENATION-JOINING STRINGS
Strings may also be concatenated (put or joined together) through the use of the "+" operator.
Try the following: