Sharp MZ-700 Series Owner's Manual page 44

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

Advertisement

2. 3. 1. 3
VERIFY
(abbreviated format: V.)
Format
numeric variable
INPUT J string variable
i array element
numeric variable
. or INPUT "character string" ; string variable
i array element
I N P U T
A
I N P U T
B $
I N P U T
X ( 5 )
I N P U T
1 1
D A T A
A-
I N P U T " Y E S
O R
I N P U T
1
K E Y
I N
= " ; A
N O " ; B S
; X ( 5 )
Function
INPUT is one of the statements which is used for entering values for assignment to
variables during program execution. Program execution pauses when an INPUT
statement is encountered to allow values to be typed in from the keyboard. After
input has been completed, the values are substituted into specified variables by
pressing the |CR| key, then program execution resumes.
(Example:)
1 0
I N P U T
A , B
2 0
C = A + B
3 0
P R I N T
C
4 0
E N D
When the program above is executed, a question mark is displayed and the cursor
blinks to indicate that the computer is waiting for data input; enter any arbitrary
number, then press the| CRj key. This assigns the value entered to variable A.
After doing this, the question mark will be displayed again. The reason for this
is that two variables (A and B) are specified in the INPUT statement on line 10,
but only one value has been entered (that which is substituted into variable A).
Enter another arbitrary number and press the |CR| key again; this substitutes the
second value entered into variable B and causes execution to go on to the next
line of the program. In the example above, subsequent lines add the values of A
and B, substitute the result into C, then display the contents of C.
Since the variables used in this example are numeric variables, the computer will
display the message ILLEGAL DATA ERROR if an attempt is made to enter any
characters other than numerics. The question mark is then redisplayed to prompt
the user to reenter a legal value (a value whose type is the same as that of the varia-
ble or array element into which it is to be substituted). Be sure to enter data whose
type matches that of the variable(s) specified in the INPUT statement.
During program execution, it may be difficult to remember what data is to be
entered when the question mark is displayed; therefore, prompt strings are usually
included in INPUT statements for display on the screen as a reminder. This is done
as shown in the program example below.
1 0
I N P U T
A = " ; A
2 0
I N P U T
B = " ; B
3 0
P R I N T
A + B = ii
A + B
4 0
P R I N T
A —B = ii
A - B
5 0
P R I N T
A X B = ii
A X B
6 0
P R I N T
A / B = ii
A / B
7 0
E N D
42

Advertisement

Table of Contents
loading

Table of Contents