The Get Command - Commodore 128 System Manual

Hide thumbs Also See for 128:
Table of Contents

Advertisement

The GET command

There are other BASIC commands you can use in your program
to interact with the computer. One is the GET command and is
similar to INPUT. To see how the GET command works, clear the
computer's memory and type this program.
10 GET A$
20 IF A$=" " THEN 10
30 ? A$
40 END
When you type RUN and press RETURN, nothing seems to
happen. The reason is that the computer is waiting for you to
press a key. The GET command, in effect, tells the computer to
check the keyboard and find out what character or key is being
pressed. The computer is satisfied with a null character (that is,
no character). This is the reason for line 20. This line tells the
computer that if it gets a null character, indicated by the two
double quotes with no space between them, it should go back to
line 10 and try to GET another character. This loop continues
until you press a key. The computer then assigns the character
on that key to A$.
The GET command is very important because you can use it, in
effect, to program a key on your keyboard. The example below
prints a message on the screen when Q is pressed. Type the
program and RUN it. Then press Q and see what happens.
10 ?" PRESS Q TO VIEW MESSAGE"
20 GET A$
30 IF A$=" " THEN 20
40 IF A$=" Q" THEN 60
50 GOTO 20
60 FOR 1=1 TO 25
70 ? "NOW I CAN USE THE GET STATEMENT"
80 NEXT
90 END
Notice that if you try to press any key other than the Q, the
computer will not display the message, but will go back to line 20
to GET another character.
4-9

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

128d

Table of Contents