This subroutine was written for the T/S 1000 in the BASIC language. It will also work on the T/S 1500, and probably on many other computers. It may be used to input any single-digit number (from zero through nine), perhaps after a menu has been printed.
This subroutine has some advantages compared to an INPUT instruction. With this subroutine, the user presses only one key per character (without pressing ENTER). Also, if the user does not wish to respond to the prompt, the BREAK key may be used to interrupt the program.
10 REM INPUT SUBROUTINE.
11 IF INKEY$<>"" THEN GOTO 11
12 PRINT AT 21,1;"? "
13 LET A$=INKEY$
14 IF A$="" THEN GOTO 13
15 PRINT AT 21,1;A$
16 IF A$<"0" OR A$>"9" THEN GOTO 11
17 LET I=VAL A$
19 RETURN
Line 11 makes the program wait, if necessary, until the system is ready to receive a new character from the keyboard. Line 12 prints a question mark near the lower left corner of the screen. It also erases the next five spaces, to finish deleting the previous value (even if it was a shifted command word). In line 12, I really use an inverted question mark — but this printer has no inverse characters.
The user presses one key (without pressing ENTER). Line 13 gets this character and stores it in A$. Line 14 makes the program wait until the user has pressed a key. Line 15 prints the character, and line 16 tests it. Rejected characters are erased and ignored, instead of interrupting the program with error code “C”.
Line 17 converts the character to a numeric value. Some programs may not need this line.
This routine was derived from a typewriter routine in the Timex User Manual. Many variations are possible. The location of the “cursor” (the question mark) could be moved by modifying the “21,1” in lines 12 and 15. Line 16 could be modified to agree with a different menu, provided each choice is represented by a single character. The character need not be numeric.
This routine is not designed for entering multiple-character values. It is usually best to use an INPUT instruction for such values. However, it would be possible to write a routine which would accept multiple-character values keyed without ENTER, provided the count of characters for that value is constant.
The first word on each line is a single-key instruction. In lines 11, 14, and 16, “GOTO” is a single-key command word, and “THEN” and “OR” are shifted single-key items. In line 11, the <> must be obtained by pressing shifted T. In line 12, I obtain an inverse question mark by pressing shifted 9 (GRAPHICS) to get the inverse G cursor, pressing the normal question mark (shifted C), and pressing the shifted 9 again to exit GRAPHICS mode. In lines 11, 13, 15, and 17, to obtain “INKEY$”, “AT”, and “VAL”, press FUNCTION (shifted ENTER) to get the inverse F cursor first, and then press the single-key “word”. Line 16 will occupy 2 lines on your screen; that’s normal. (Everything in this paragraph applies to TIMEX BASIC only).
To use the subroutine, a GOSUB instruction is required. GOSUB 10 will work on my computer, but I use GOSUB 11 for efficiency.
If there are any questions about this subroutine, please contact me at Soft Answer, phone (301) 474-7922.
[Switching lines 11 and 12 may improve this. Ed.]
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.