Commodore 2001-8 User Manual page 41

Table of Contents

Advertisement

generally this is not a good idea because the purpose of GET is to scan the keyboard and return with a
single key closure. When a numeric value is specified
GET A
only numeric keys will be accepted as input. All others will cause the message:
?SYNTAX ERROR
Use of the numeric value is confusing because if no key has been struck, the value returned is zero.
Otherwise it will have a value 1·9 for keys 1-9.
The most desireable way to use GET is with a string variable. If a key has not been pressed, the string
will have a null value (length
=
0); otherwise the string will contain the character corresponding to the key
that was pressed. See the next section for a detailed explanation of how strings work.
GET calls a routine which examines the keyboard interrupt buffer. If the buffer is empty, the variable
contains a value of null or zero. If there are characters, the first is taken out of the queue and returned.
Since the length of queue is 10 characters, calling GET 10 times In a loop is a good way to insure that the
queue is empty when waiting for a response. This is particularly useful In interactive games.
The following routine will wait for a key to be pressed and exit only with the value of a key closure:
10 GET A$
20 IF A$=""THEN 10
In this case, ""is a literal which contains no characters and is a null string.
NOTES
37

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents