Commodore 2001-8 User Manual page 39

Table of Contents

Advertisement

Commas within quotes will not be treated by BASIC as field terminators.
60 DATA ",",","
It is also possible to type mixed alphanumeric and data fields. Numeric fields may be treated as alpha.
10 DATA 123, ABC, 345
20 READ A, A$, B
It ;s adviseable for the programmer to know how many data statements he has put into the machine or
use some kind of a delimeter at the end of the data. If it is not done, the data is continuously read, and the
program will index its way through all of the data statements. Finally, DATA will be exhausted and when
the next READ is encountered an ?OUT OF DATA ERROR
will occur. Sometimes you may also see this error if you carriage return through READY on the screen
because the PET thinks you already told it to READ Y.
SYNTAX error results when an attempt to read alpha field into a numeric variable is made.
READ and DATA are implemented in the following manner: The first byte of text contains a zero. This is
really not part of the first line but is a dummy line consisting only of a terminator. When RUN is typed, a
data statement pointer is directed to this byte. Since it is pointing to a terminator, the first READ
command initiates a search for a DATA statement token.
There is one other command available to the programmer which allows him to reuse the stored data.
RESTORE restart the DATA search back to the beginning of memory.
The following program would correctly operate continuously re-reading DATA;
10 DATA 10, 20, 30, 40, 50, 60,70
20 1=1
30 READ A: PRINT A
401=1+1
50 IF 1<8 THEN 30
60 RESTORE
70 GO TO 20
INPUT
When interactive response to DATA requirements became possible, the concept of INPUT from the
keyboard was introduced. Since the classical input device to BASIC was a TTY, the format of input
statements was limited by this device.
Operation of INPUT is considerably enhanced when coupled with the powerful PET screen editor.
The form
of
the statement
Is
the verb INPUT followed by
a
variable list. INPUT
satisfies
the variables in
sequence.
INPUT A, B, C
When BASIC encounters this Instruction, It prints
a
question mark to the screen then activates the screen
editor, blinking the cursor for input. Because you are under control
of
the screen editor, cursor movement
characters are allowed up until the carriage return
is
issued
as a
terminator.
After carriage return
is
received, data
is
handed back to
BASIC
one character at
a
time. Data
is
then
interpreted by
BASIC
using its input buffer and rules of interpretation.
Leading blanks are supressed, so if you are inputting a string which requires blanks or literals, it is
necessary to enclose the input characters within quotes.
The editor picks up only the characters between the question mark and the current position of the cursor.
35

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents