3 - 38 3 - 38
MELSEC-Q
3 LET'S CREATE AND EXECUTE A PROGRAM
The INPUT instruction pauses the program until data is entered and the Enter key is
pressed. When you don not wish to pause the program, the INKEY$ function is used.
the following shows an example program:
Example
…
…
…
A
A
"A" is displayed on the screen when the A key is pressed.
When the A key is released, the screen will be blank again.
No output is displayed on the screen even after execution.
Now press the A key.
10 A$=INKEY$
20 PRINT A$
30 GOTO 10
RUN
Full-byte characters
(Kanji characters)
cannot be used as
an input with the
INKEY$ function.
As you can see, the INKEY$ function checks for the keyboard status and the program
is not be paused. The INKEY$ function uses an empty as the value, and uses the text
as the value when a key is pressed. However, since this value is a character string,
the substituted variable must be a character variable or a character array.
Furthermore, unlike the INPUT function, multiple characters cannot be input once.
Example
Y
Y
Press the key.
10 N=0
20 PRINT "Count in progress"
30 N=N+1
40 K$=INKEY$
50 IF INKEY$= "Y" THEN GOSUB 70
60 GOTO 30
70 PRINT "N= ";N;"
80 RETURN
RUN
Count in progress.
N = 30.
N= 530.
Press the key.
10 PRINT "Press the Y key."
20 K$=INKEY$
30 IF K$= " Y" GOTO 50
40 GOTO 20
50 END
If the INKEY$ function is used to wait for an input as
shown below, the efficiency of multitask execution may
be degraded.
10 PRINT "Press the Y key."
20 K$=INPUT$(1)
30 IF K$<> " Y" GOTO 20
40 END
Use the INPUT$ function in the following case
Содержание A1SD51S
Страница 183: ...11 13 11 13 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS RUN Before swap A 0 H924 A 1 H1159 After swap A 0 H1159 A 1 H924 OK...
Страница 331: ...11 161 11 161 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CON ON OFF STOP and ZOPEN functions and Section 7 4...
Страница 557: ...11 387 11 387 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the CHR SPACE and SPC functions...
Страница 629: ...11 459 11 459 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZOPEN ZSEND and ZCNTL instructions and Section 7 3 4...
Страница 645: ...11 475 11 475 MELSEC Q 11 INSTRUCTIONS AND FUNCTIONS REMARK See the ZEVENT ZSIGNAL and DEF ZEVENT instructions...