The computer can give you the ASCII code for a character. For example:

PRINT ASC("A") RETURN

prints 65. Note that ASC works with single characters only. If you want the

ASCII codes for a series of characters you should consult the table showing the

full character set in Appendix 2.

In the previous two programs the ASCII code is stored in the variable chosen. If

no key is pressed before the INKEY time limit is reached, chosen is given the

value -- 1.

GET or INKEY do not automatically display the character typed at the

keyboard. This is useful in programs where printing would spoil the screen

display. If you do want to print the character, use PRINT CHR$ to convert the

ASCII code into a string:

10 MODE 135

20PRINT "Type any character -- " ;

30 chosen=GET

40 PRINT CHR$(chosen)

50 PRINT "You typed ";CHR$(chosen)

VDU followed by an ASCII code has the same effect as PRINT CHR$. For

example, both PRINT CHR$(65) and VDU 65 would print the letter A. If you

type:

VDU 66,66,67 RETURN

the computer prints:

BBC

The ASCII codes for the characters start at 32. Lower codes are used to give

commands to the computer, as you have seen with VDU 26 and VDU 28.

Structured programs

In the last section you were introduced to some of the most commonly used

commands from BBC BASIC. Most of these commands dealt with the ways in

which you can communicate with the computer while a program is running,

and how you can effect the way the computer displays information on the

screen.

C 29