Commodore 64 User Manual page 103

Hide thumbs Also See for 64:
Table of Contents

Advertisement

It is important to follow the format of the DATA statement precisely:
40 DATA 1, 34, 10.5, 16 , 234.56
T
T
Comma separates
No Comma
each item
Data statements can contain integer numbers, real numbers (234.65),
or numbers expressed in scientific notation. But you can't READ other
variables, or have arithmetic operations in DATA lines. This would be
incorrect:
40 DATA A, 23/56, 2*5
You can, however, use a string variable in a READ statement and then
place string information in the DATA line. The following is acceptable:
NEW
10 FOR > = 1 to 3
15 READ AS
20 PRINT "A$ IS NOW As
30 NEXT
40 DATA 'THIS. IS. FUN
RUN
AS IS NOW THIS
AS IS NOW IS
AS IS NOW FUN
READY
Notice that this time, the READ statement was placed inside a FOR
. . . NEXT loop. This loop was then executed to match the number of
values in the data statement.
In many cases you will change the number of values in the DATA
statement each time the program is run. A way to avoid counting the
number of values and still avoid an OUT OF DATA ERROR is to place a
"FLAG" as the last value in the DATA line. This would be a value that
your data would never equal, such as a negative number or a very
large or small number. When that value is READ the program will
branch to the next part.
There is a way to reuse the same DATA later in the program by RE-
93

Hide quick links:

Advertisement

Table of Contents
loading

Related Products for Commodore 64

Table of Contents