Using
CHR$
and ASCII values makes
it
possible to program or do com-
parison checking for cursor controls such
as
RETURN
and
INSERT
/DELETE. Sup-
pose a program must check incoming characters from the keyboard to
see
if the
programmer depressed the
RETURN
key; this may
be
needed when using
an
IN-
PUT
or
GET
statement. Vou could check for a
RETURN
which
has
an
ASCII code of
13,
as
follows:
1(1
GET
;";$
2(1
IF
X$=CHR$(13)
GOTO
340
30
GOTO
10
This test would
be
impossible if vou tried to
put
a
RETURN
between quota-
tion marks:
21<:1
IF
;:";$='"
F:ETUF.:N l''OI)TO
340
t
Impossible
This
is
impossible because when vou depress the
RETURN
key following a set of
quotes,
it
automatically moves the cursor to the next line:
As vou can
see,
use of the
CHR$
function and ASCII numbers
is
extremelv
helpful because
it
allows vou to program characters and controls
which
could not
otherwise
be
programmed.
ARITHMETIC
With
the PET, vou can
do
addition, subtraction, multiplication, and
division, using
up
to 9-digit numbers
in
either calculator mode
or
program
mode.
A 9-digit length
limit
can cause problems.
For
example. integer numbers
range from 0 to 999999999; in dollars and cents this gives vou a range of $0.00 to
$9,999.999.99
(or
$999.999,999 if cents are not used). Fractional numbers mav
range from 0.000000001 to 99999999.9. Although these limits pose no problems
in manv applications, numbers
will
frequent1v exceed these limits in business and
scientific applications.
Two
programming methods can overcome the PET's numeric length
limitations. The first method calculates the numbers
as
numeric strings. The
second method calculates
with
multiple integer math, where a large number
is
separated into smaller segments,
and
each segment
is
handled separately.
189