Keyboard input/Obtain a Y or N response: Difference between revisions
Content added Content deleted
No edit summary |
m (→{{header|GWBASIC}}: Fixed GW-BASIC header) |
||
Line 291: | Line 291: | ||
The loop on lines 30 - 40 will cycle as fast as the interpreter can go, assigning K$ the empty string until the user presses a key. On versions of BASIC later than the 2.0 on the VIC and 64 (e.g. 3.5 on the C-16 and Plus/4, 7.0 on the C-128), GETKEY may be used in place of GET. GETKEY will wait for the user to press a key before continuing, so the polling is done in the BASIC interpreter's machine language code, and the BASIC loop only cycles when the user presses a key other than Y or N. |
The loop on lines 30 - 40 will cycle as fast as the interpreter can go, assigning K$ the empty string until the user presses a key. On versions of BASIC later than the 2.0 on the VIC and 64 (e.g. 3.5 on the C-16 and Plus/4, 7.0 on the C-128), GETKEY may be used in place of GET. GETKEY will wait for the user to press a key before continuing, so the polling is done in the BASIC interpreter's machine language code, and the BASIC loop only cycles when the user presses a key other than Y or N. |
||
==={{header| |
==={{header|GW-BASIC}}=== |
||
{{works with|QBasic}} |
|||
<lang gwbasic>10 CLS: PRINT "Press Y or N to continue." |
<lang gwbasic>10 CLS: PRINT "Press Y or N to continue." |
||
20 WHILE T$<>"y" AND T$<>"Y" AND T$<>"n" AND T$<>"N" |
20 WHILE T$<>"y" AND T$<>"Y" AND T$<>"n" AND T$<>"N" |
||
Line 304: | Line 304: | ||
</lang> |
</lang> |
||
===={{header| |
===={{header|GW-BASIC variant}}==== |
||
⚫ | |||
<lang gwbasic> |
|||
⚫ | |||
20 CLS: PRINT "Press Y or N to continue." |
20 CLS: PRINT "Press Y or N to continue." |
||
30 WHILE T$<>"Y" AND T$<>"N" |
30 WHILE T$<>"Y" AND T$<>"N" |
||
Line 312: | Line 311: | ||
50 IF T$<>"Y" AND T$<>"N" THEN BEEP |
50 IF T$<>"Y" AND T$<>"N" THEN BEEP |
||
60 WEND |
60 WEND |
||
70 PRINT "The response was: "; T$ |
70 PRINT "The response was: "; T$</lang> |
||
</lang> |
|||
==={{header|IS-BASIC}}=== |
==={{header|IS-BASIC}}=== |