Chapter 3 Programming the
VIC
20
Computer
107
You must enter some text followed by a comma, then
an
integer
number followed by a comma, then a floating point number followed by
RETURN. Any departure from this input sequence will cause
an
error;
following
an
error the computer displays two question marks. You will have
to reenter the
data
in the correct format.
If
the computer then displays a
question mark with the message REDO
FROM
START, enter the data
again.
Now rewrite the
PRINT
statement so
that
A$,
A,
and
A%
are in
an
order that differs from the
INPUT
statement. Rerun the program.
As
we
discussed earlier, any integer can be represented using a floating
point number. Therefore, you can input
an
integer value for a floating point
variable. You cannot input a floating point value for
an
integer variable,
however. You cannot enter text for
an
integer
or
a floating point number,
but
you can enter a number for a text variable; the number will be inter-
preted as characters rather than a numeric value. Try these variations to
satisfy yourself that you understand the data entry options.
The
INPUT
statement
is
very fussy; its syntax
is
too demanding for any
normal human operator. Imagine the office worker who knows nothing
about
programming.
On
encountering the types
of
error messages
that
can
occur if one comma
is
out
of place, one may well give up in despair. You are
therefore likely to spend a lot
of
time writing "idiot-proof" data entry
programs; these are programs
that
are designed to watch out for every
conceivable type
of
mistake
an
operator can make when entering data. An
idiot-proof program will cope with errors in a way
that
the operator can
understand. Chapter 4 describes data entry programming in detail.
One simple trick worth noting
is
the
INPUT
statement's ability to
display data. You can precede each item
of
data entry with a short message
telling the operator what to do. The message appears in the
INPUT
state-
ment as text between quotes. A semicolon must occur after the text to be
displayed and before the first input variable name. Here
is
an
example.
18
INPUT
"ENTER
THE
NUMBER
l"iN
28
IF
N<>l
THEN
OOTO
50
30
PRINT
"01("
40
OOTO
40
50
PRINT"NO,
DUMMY,"
60
GOTO
10
This program prints a message, then waits for a single data entry.
The
prompting feature
of
INPUT
does have a pitfall, however:
If
the