The Restore Command - Commodore 128 System Manual

Table of Contents

Advertisement

again, it assigns the value the pointer indicates to the variable
name in the READ statement.
You can use as many READ and DATA statements as you need
in a program, but make sure there is enough data in the DATA
statements for the computer to read. Remove one of the numbers
from the DATA statement in the last program and run it again.
The computer responds with ?OUT OF DATA ERROR IN 30.
What happened is that when the computer executed the loop for
the fifth time, there was no data for it to read. That is what the
error message is telling you. Putting too much into the DATA
statement doesn't create a problem because the computer never
realizes the extra data exists.

The RESTORE Command

You can use the RESTORE command in a program to reset the
data pointer to the first piece of data if you need to. Replace the
END statement (line 80) in the program above with:
80 RESTORE
and add
85 GOTO 10
Now RUN the program. The program will run continuously using
the same DATA statement. NOTE: If the computer gives you an
OUT OF DATA ERROR message, it is because you forgot to
replace the number that you removed previously from the DATA
statement, so the data is all used before the READ statement has
been executed the specified number of times.
You can use DATA statements to assign values to string
variables. The same rules apply as for numeric data. Clear the
computer's memory and type the following program:
10 FOR J=1 TO 3
20 READ A$
30 ? AS
40 NEXT
50 END
60 DATA COMMODORE,128,COMPUTER
4-12

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

128d

Table of Contents