Sharp PC-1500A Instruction Manual page 58

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

Advertisement

All
and
more about
Sharp
PC-1500 at
http:f/www.
PC-1500.info
10
DATA
1,2,3
20
READ A, B, C
30
READ D
To
correct
this >ituation,
we
may add a data
item
to
line
10:
10
DATA1,2,3,65
..2!:..
i.ve may
use a separate
DATA
statement,
anywhere
within
the prooram:
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
o
single
list
of data
items. As
the
computer
encounters
each
variable
name
within a READ
statement,
it
assigns 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
varinble
to be
filled, an error will
occur.
Good
programmers group
data
items
into
separ<>te
DATA state·
mcnts,
each
of
which corresponds
to its
READ
statement
within the program.
This is illustrated
in the following program which
reads
three
data
items
four
times:
10
DATA 1, "A'',
1
20 DATA
2,
"O",
3
30
DATA
5,
..
" , a
40 DATA 13,
"D",
21
50 FOR
I
=
1
TO
3
60
READ A, AS,
Z
70
T=T+A*Z
80
NEXT
I
Lines
10 through
40
could have
been
written as:
10
DATA
1.
"A",
1, 2,
"8",
3,
5, "C", 8.
13, ''0"', 21
or even
as:
10
DATA
1
20
DATA "A"
30
DATA 1
40
DATA 2
Cetcl
Both of the$e alternate
forms obscure
the
fact
that
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
56
Do
not
sale
this PDF!!!

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents