Keyboard input/Obtain a Y or N response: Difference between revisions
Content added Content deleted
(added MiniScript example) |
Childishbeat (talk | contribs) m (→{{header|BASIC}}: The examples under the BASIC header are now in alphabetical order, hopefully making it easier for more people to find the specific example they're looking for.) |
||
Line 102: | Line 102: | ||
</lang> |
</lang> |
||
==={{header| |
==={{header|BBC BASIC}}=== |
||
<lang |
<lang bbcbasic> REPEAT UNTIL INKEY$(0) = "" |
||
PRINT "Press Y or N to continue" |
|||
⚫ | |||
⚫ | |||
key$ = GET$ |
|||
UNTIL key$="Y" OR key$="N" |
|||
PRINT "The response was " key$</lang> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | 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|GWBASIC}}=== |
==={{header|GWBASIC}}=== |
||
Line 122: | Line 132: | ||
90 PRINT "The response was "; T$ |
90 PRINT "The response was "; T$ |
||
</lang> |
</lang> |
||
⚫ | |||
<lang IS-BASIC>100 GET K$ ! Flush the keyboard buffer |
|||
⚫ | |||
⚫ | |||
130 LET K$=LCASE$(INKEY$) |
|||
⚫ | |||
⚫ | |||
==={{header|Locomotive Basic}}=== |
==={{header|Locomotive Basic}}=== |
||
Line 142: | Line 160: | ||
40 IF k$ <> "y" AND k$ <> "Y" AND k$ <> "n" AND k$ <> "N" THEN GO TO 30 |
40 IF k$ <> "y" AND k$ <> "Y" AND k$ <> "n" AND k$ <> "N" THEN GO TO 30 |
||
50 PRINT "The response was "; k$</lang> |
50 PRINT "The response was "; k$</lang> |
||
⚫ | |||
<lang bbcbasic> REPEAT UNTIL INKEY$(0) = "" |
|||
⚫ | |||
⚫ | |||
key$ = GET$ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | 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|Batch File}}== |
=={{header|Batch File}}== |