Sharp PC-1500 Instruction Manual page 58

Hide thumbs Also See for PC-1500:
Table of Contents

Advertisement

All
and more about Sharp PC-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 line
10:
10 DATA 1,2, 3,
65
.Q!'..
we may use a
separate OATA statement, anywhere
within the
program
:
10 DATA
1,
2, 3
20
READ
A,
B,
C
30 READ
D
40
DATA
65
This illustrates
that
SHARP views all
of
the
DATA statements
within
a
program
as
a single list
of data items. As
the
computer
encounters each
variable name
within a READ
statement,
it
a.ssigns
the next
data item from the
list
to
that variable.
If
SHARP cannot fulfill
a
request for
a
data
item
it stops the
program and
signals
an error.
Extra
items
which
are unused when the
program finishes
in
a normal
manner, are
ignored.
If the
type (character
or numeric)
of the next
item
does
not
match
the type
of
the variable
to
be
filled,
an
error
will occur.
Good
programll1lers
group data
items into
separ
ate
DATA state·
ments,
·each
of which
corresponds to its READ
statement
within the program.
T
his 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 DATA
40
DATA
2
(etc)
Both
of
these
alternate fo
rms
obscure the
laci
ihat
three data
items
are read,
each
time, 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
!!!

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents