Commodore PET User Manual page 196

Table of Contents

Advertisement

However. if a number is entered enclosed within quotation marks or entered
as a string with an INPUT statement (or other similar statement such as GET or
READl. the numeriC string is treated like any other alphabetic or graphie string
and no blank for a positive sign value is inserted before the number. This is
demonstrated in the following program:
1 (1 AB= 12345
20 T$="12345"
30 PRIHT"AB=".; AB
40 PRnn"T$=".; T$
F.:UN
AB= 12.345
T$=12345
Notice that there is no preceding blank printed in the T$ string above.
Concatenating Numeric Strings
Lefs concatenate two strings. T$ and Q$. to make a new string. W$. W$
should contain the ten digits 1.2.3.4.5.6.7.8.9.0.
10 T=12345
20 Q=6789(1
3(1 T$=STF.:$(T)
4(1 Q$=STF.:$ (G!)
51:::1 lol$=T$+Q$-Create new string
W$
60
PF~
1HT"W$="; W$
The result would be:
W$= 12345 67890
Why the embedded blanks before the 1 and
67
T$ and Q$ were originally
positive numeric variables T and Q; when T and Q were converted from numbers
into strings. the sign position was transferred along with the number.
Therefore. when T$ and Q$ are concatenated. the new string W$ contains a
first-digit blank and an embedded blank before the first digit of Q$.
T$
+
Q$
W$
Itt11121314151 Ittla!7!819Ioj IttI11213141*laI71819IOI
How do we get rid of the embedded blanks
7
The solution to this problem is
mu ch simpler than it may at first appear. The method is not to attack the contents
of W$ and try to get rid of the blanks there. but to go back to where the blanks
first pose a problem; when they are in the separate strings T$ and Q$. Look again
at the contents of T$ and Q$:
183

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cbm

Table of Contents