1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

3.3 Text Input from the keyboard

For text input, there are three main methods-- INPUT, GET, and some
fun with PEEKs and POKEs. The first two are blocking methods that stop
the current program and wait for input to be typed in; the third hits
the hardware on the machine to see if a character has been typed and
get the currently typed character.

INPUT is the most powerful of the lot. It can get integers, reals, and
strings, as well as getting several at once. 'INPUT A' displays a '?',
flashes the cursor and lets the user type in a number. 'INPUT A,B'
wants two numbers, separated by a comma. If the user hits return
instead of a comma after the first number, a '??' will appear and the
user can type the next number. Strings and integer variables can be
similarly inputted. You can also use a string constant as the first
parameter of an INPUT to give a line of text to be printed before
anything is input: 'INPUT "What is your name?";NAME$' will do just
that.

Note: INPUT can be very poor about parsing multiple strings, numbers,
and the like. You may wish to program your own ones that have much
better functionality.

'GET' is like INPUT except that it only waits for one character, and
returns immediately on getting that without printing it to the screen.
Thus, 'GET A$' is an excellent way of waiting for any key, or building
a better INPUT, etc. GETting a real or an integer is not really
recommended-- if the user types a non-numeric character (0-9, +, -, ,,
E, etc), the program will stop with an error.

The final, and most on the metal method, is to read the 1-character
input buffer yourself. If the return value from 'PEEK (49152)' ('PEEK
(-16384)') is identical, but uses one more character) is less than
128, nothing has been hit. If it is greater than 128, the key hit has
ascii value of the return value minus 128. Thus, 'A$=CHR$(PEEK
(49152)-128)' will set A$ to the key that was hit. 'POKE 49168,0'
('POKE -16368,0' is also identical) will tell the system that you've
dealt with the keypress; if this is not done, it'll continually report
that one key down.

It is also possible to combine this: 'WAIT 49152,128' (identical in
function to 'WAIT -16384,128') pauses the system without flashing the
cursor until a key is hit without eating the key, so an immediate GET
will grab the key just hit.

3.4 Low Resolution (Lores) graphics

This graphics mode is always available, and provides 40x40 + 4 lines
of text or 40x48 graphics on the screen with 16 fixed colors
available. It does this by replacing each character on the text screen
with two blocks. [Since the screens are in the same memory location,
you can use Lores graphics commands to put stuff on your screen.
Experiment around!]

The Lores graphics screen can be turned on in "mixed" mode of 40x40
with 4 lines of text at the bottom with the 'GR' command. This clears
all of the 40x40 field to black, and puts the current prompt line in
the space at the bottom. 'COLOR=n' sets the color to the appropriate
selection. Valid colors are 0 (Black), 1 (Magenta), 2 (Dark Blue), 3
(Violet), 4 (Dark Green), 5 (Dark Gray), 6 (Medium Blue), 7 (Light
Blue), 8 (Brown), 9 (Orange), 10 (Light Gray), 11 (Pink), 12 (Bright
Green), 13 (Yellow), 14 (Aqua) and 15 (White). If the value for your
color is greater than 15, only the remainder when divided by 16 is
used, so 'COLOR=16' is equivalent to 'COLOR=0' and the like.