EasyManua.ls Logo

Commodore PET - Page 196

Commodore PET
447 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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~
1
HT"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 blanks7 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

Table of Contents

Related product manuals