Authors
Publication
Pub Details
Date
Pages
BASIC Terms
One day, as I was rummaging through the TS2068 ROM, I discovered that there was more to the INPUT command than what was described In the manual. Digging a little deeper, I found that what’s presented here is covered In detail In the Spectrum manual. Well, so much for international communications.
The TS2068 manual tells us that the INPUT command lets you insert a prompt at the bottom of the screen. No doubt, you have seen this many times:
10 INPUT "ENTER DESIRED VALUE:";x
The effect of this line is to print at the bottom of the screen the words-ENTER DESIRED VALUE. The input cursor follows this prompt, and the computer waits for you to type in some number which will go into the variable X.
That’s pretty basic stuff. Did you know that instead of putting a prompt between quotation marks, you can also refer to string and numeric variables? Consider these lines:
10 LET A$="ENTER DESIRED VALUE:"
20 INPUT (A$);X
Here, the effect is the same. The prompt gets printed along with the input cursor. It is done not with quotes, but with parentheses and reference to A$. This opens up many possibilities. For example, in a game for many players:
10 INPUT "HOW MANY PLAYERS?";P
20 DIM N$(P,5): FOR X=1 TO P
30 INPUT ("TYPE THE NAME FOR PLAYER ";X);N$(X)
40 NEXT X
And then, later in the game you could have:
100 FOR X=1 TO P
110 INPUT (N$(x);", WHAT'S YOUR MOVE?");A$
120 NEXT X
A variation on this theme might be typing in a long list of numbers or words. You can use this quick and dirty input routine to tell you what the current value for a variable is before entering a new value.
1 DIM A(10)
10 FOR X=1 TO 10
20 INPUT ("current value for A (;X;") IS: ";A(X));TAB 0; " NEW VALUE? ";B$
30 IF B$<>"" THEN LET A(X)= VAL B$
40 NEXT X
You can, in fact, use AT, TAB, INK, FLASH or any other print parameter in conjunction with the input command. The only rule to follow is that any item which begins with a letter of the alphabet will become the variable which takes on the value you type in UNLESS the item is enclosed with quotes.
Have fun experimenting with this. If you want more information on the INPUT command, try to obtain a copy of the Sinclair Spectrum User’s Manual.
Products
Media
Image Gallery
Source Code
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.