17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

GW-BASIC <strong>User's</strong> Guide<br />

INKEY$ Variable<br />

Purpose:<br />

To return one character read from the keyboard.<br />

Syntax:<br />

v$=INKEY$<br />

Comments:<br />

If no character is pending in the keyboard buffer, a null string (length zero) is returned.<br />

If several characters are pending, only the first is returned. The string will be one or two<br />

characters in length.<br />

Two character strings are used to return the extended codes described in Appendix C of the GW-<br />

BASIC <strong>User's</strong> Guide. The first character of a two character code is zero.<br />

No characters are displayed on the screen, and all characters except the following are passed to<br />

the program:<br />

CTRL-BREAK<br />

CTRL-NUM LOCK<br />

CTRL-ALT-DEL<br />

CTRL-PRTSCR<br />

PRTSCR<br />

Examples:<br />

10 CLS: PRINT"PRESS RETURN<br />

20 TIMELIMIT% = 1000<br />

30 GOSUB 1010<br />

40 IF TIMEOUT% THEN PRINT "TOO LONG" ELSE PRINT "GOOD SHOW"<br />

50 PRINT RESPONSE$<br />

60 END<br />

.<br />

.<br />

.<br />

1000 REM TIMED INPUT SUBROUTINE<br />

1010 RESPONSE$=""<br />

1020 FOR N%=1 TO TIMELIMIT%<br />

1030 A$=INKEY$:IF LEN(A$)=0 THEN 1060<br />

1040 IF ASC(A$)=13 THEN TIMEOUT%=0: RETURN<br />

1050 RESPONSE$=RESPONSE$+A$<br />

1060 NEXT N%<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/INKEYS.html (1 of 2)28/03/2004 21.29.30

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!