3 - 37 3 - 37
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
3.11 Entering Data Using the Keyboard
There are two methods to notify data entered via keyboard to BASIC. One method is
using the INPUT instruction, which BASIC pauses the program and waits for an input.
The other is the function INKEY$ that simply checks for keyboard status and doesn't
stop the program.
The INPUT instruction is used when you wish to pause the execution by BASIC while
data is being entered.
The INPUT instruction is used as follows.
INPUT Variable name in which to place data
Example
BASIC is asking for the value of A. For example, if "6" is the value
for A, input "6" and press the Enter key.
Similarly, BASIC is asking for the value of B.
For example, input "10" and press the Enter key.
10 INPUT A
20 INPUT B
30 PRINT A+B
40 END
RUN
? 6
? 10
16
OK
BASIC waits until the
Enter key is pressed.
Sometimes it is difficult to understand what BASIC is asking for, if only '?' is displayed
on the screen. Therefore, there is a function to specify a character constant. See the
program below.
Example
10 INPUT " A=" ;A
20 INPUT " B=" ;B
30 PRINT A+B
40 END
RUN
A=?6
A=?10
16
OK
As shown above, it's now clear as to what the program is asking for when a character
constant is placed in front of the variable name separated by a semicolon.