A
ll
and more about Sharp P
C-
1500 at http://www.PC-1500.info
10
DATA 1,
2,
3
20
READ A,
B,
C
30
READ D
To correct this situation,
we
may add a data item to
li
ne 10:
10
DATA 1
,2
, 3,
65
.Q!'..
we may use a separate OATA
stat
ement, anywhere within
the
program:
10
DATA 1, 2, 3
20
READ A, B, C
30
READ D
40
DATA 65
This illustrat
es
t
hat
SHARP views
all
of
the
DATA statements
with
in a program
as
a single list
of
data items.
As
the
computer encounters each variable name within a READ statement,
it
a.ssig
ns the next
data
item fr
om
the
list
to
that
variable.
If
SHARP
cannot
fulfill a request for a
data item
it
stop
s
the
program and signa
ls
an error. Extra items which are unused when the
program
finishes
in a normal manner,
are
i
gno
red.
If
the
type
(cha
racter
or
numeric)
of
the
next
item does not match
the
type
of
the variable
to
be filled,
an
error
will
occ
ur. Good program
ll1lers
group data
it
ems
into
separate DATA stateĀ·
ments, Ā·each
of
which corresponds to its
READ
statement
within the program. This
is
illustrated
in
the
following program
v1hich
reads
three
data items four
times:
10 DATA
1,
"A", 1
20
DATA 2,
"B",
3
30 DATA 5,
"C", 8
40
DATA 13,
"D",
21
so
FOR I = 1 TO 3
60
READ A, A$, Z
70
T =
T+A*Z
80
NEXT I
Lines
10
through
40
could have been written as:
10 DATA 1,
"A"
,
1,
2,
"B"
,,
3,
5,
"C",
8,
13,
"0",
21
or
even
as
:
10
DATA
20
DATA
"A"
30
DA
TA
40
DATA 2
(etc)
Both
of
these alternate forms obscure
the
laci
ihat
three
data
items are read,
eac
h tim
e,
by
the
READ statement. The alternate forms also make
it
more difficult to verify
the
types
of
the
data
S6
Do
not sale this PDF
!!!