INPUT ignores any spaces at the beginning of an input or anything typed after
a comma:
What is your name ? Nero,Emperor of Rome
Hello Nero. Pleased to meet you.
If you need to type in text that includes spaces at the start or may include
commas, you should use INPUT LINE rather than INPUT:
20 INPUT LINE "What is your name ";name$
This gives:
What is your name ? Nero,Emperor of Rome
Hello Nero,Emperor of Rome. Pleased to meet you.
GET and INKEY
In some programs, such as games, the computer needs to respond as soon as a
key is pressed. Programs like this use GET or INKEY rather than INPUT
statements. GET waits until a key is pressed before continuing:
10 MODE 135
20 PRINT "Press any key to continue"
30 chosen=GET
40PRINT "The program has ended."
INKEY causes the computer to wait for a key to be pressed within a fixed time:
10 MODE 135
20 PRINT "Press any key to continue"
30 PRINT "You have 3 seconds only !"
40 chosen=INKEY(300)
50 PRINT "The program has ended."
The timing is in hundredths of a second, so line 40 makes the computer wait for
a key depression for three seconds (300 hundredths of a second). If no key is
pressed within three seconds, the computer moves on to the next line of the
program. If a key is pressed, the computer immediately continues with the next
line of the program.
ASCII codes
Both GET and INKEY produce what is called the ASCII code of the depressed
key. Internally, the computer uses a number from 0 to 255 to represent each
character that it stores in its memory. This number is the character's ASCII
code. For example, the ASCII code for A is 65, B is 66 and C is 67, so the
computer would store the word CAB as the numbers 67, 65 and 66.
C 28