Sharp MZ-700 Series Owner's Manual page 46

Personal computer
Hide thumbs Also See for MZ-700 Series:
Table of Contents

Advertisement

2. 3. 5. 5 READ
Format
Function
DATA . .
READ
DATA
numeric variable
string variable
array element
f numeric constant
I string constant
(abbreviated format: REA. ~ DA.)
numeric variable j
>
string variable
f •
array element
i
< j numeric constant ]
1 string constant
j
>
Like the INPUT and GET statements, the READ statement is used to submit data to
the computer for processing. However, unlike the INPUT and GET statements,
data is not entered from the keyboard, but is stored in the program itself in DATA
statements. More specifically, the function of the READ statement is to read succes-
sive items of data into variables from a list of values which follows a DATA state-
ment. When doing this, there must be a one-to-one correspondence between the
variables of the READ statements and the data items specified in the DATA state-
ments.
Example
(Example 1)
1 0
R E A D
A , B , C , D
2 0
P R I N T
A ; B ; C ; D
3 0
E N D
4 0
D A T A
1 0 . 1 0 0 , 5 0 ,
6 0
RUN J
1 0
1 0 0
5 0
6 0
(Example 2)
1 0
R E A D
X $ , A 1 , Z S
2 0
P R I N T
X $ ; A 1
; Z $
3 0
E N D
4 0
D A T A
A , 1 , C
RUN J
A ^ 1 C
•In this example, values specified in the
DATA statement are read into variables
A, B, C, and D by the READ statement,
then the values of those variable are
displayed.
•As shown by the example below, string
data included in DATA statements does
not need to be enclosed in quotation
marks.
•The READ statement in this example
picks successive data items from the list
specified in the DATA statement, then
substitutes each item into the correspond-
ing variable in the list following the
READ statement.
44

Advertisement

Table of Contents
loading

Table of Contents