The Commodore 64 has a keyboard buffer that holds up to 10 characters. This means that if the computer is busy doing some operation and it's not reading the keyboard, you can still type in up to 10 characters, which will be used as soon as the Commodore 64 finishes what it was doing. To demonstrate this, type in this program on your Commodore 64:
NEW 10 TI$="000000" 20 IF TI$ < "000015" THEN 20
Now type RUN, hit d<RETURN> and while the program is RUNning type in the word HELLO.
Notice that nothing happened for about 15 seconds when the program started. Only then did the message HELLO appear on the screen.
Imagine standing in line for a movie. The first person in the line is the first to get a ticket and leave the line. The last person in line is last for a ticket. The GET statement acts like a ticket taker. First it looks to see if there are any characters "in line." In other words have any keys been typed. If the answer is yes then that character gets placed in the appropriate variable. If no key was pressed then an empty value is assigned to a variable,
At this point it's important to note that if you try to put more than 10 characters into the buffer at one time, all those over the 10th character will be lost.
Since the GET statement will keep going even when no character is typed, it is often necessary to put the GET statement into a loop so that it will have to wait until someone hits a key or until a character is received through your program. Below is the recommended form for the GET statement. Type NEW to erase your previous program.
10 GET A$: IF A$ ="" THEN 10
Notice that there is NO SPACE between the quote marks("") on this line. This indicates an empty value and sends the program back to the GET statement in a continuous loop until someone hits a key on the computer. Once a key is hit the program will continue with the line following line 10. Add this line to your program:
100 PRINT A$;: GOTO 10
|This page has been created by Sami Rautiainen.|
|Read the small print.||Last updated November 14, 1998.|