Programming by Example

 

A BB4W Compendium

freeman69@gmx.com

IDIC BBC_Owl2 M&P

ASCII Table

The American Standard Code for Information Interchange (ASCII) is an old method of referencing alphanumeric characters with a number between zero and 255. Why 255? Because computers process data in binary and 255 is the largest number that can be represented using only 8 binary digits. 11111111 in binary = 255 in decimal.

 

This program provides a useful guide to the ASCII value of a digit, letter or punctuation mark.

 

Use the character designer, from chapter one, to create your own character (e.g. number 224). Copy and paste the VDU 23 command from the text file into line 20. When the program is run you should see your character appear within the table.

 

  10 MODE 9

  20

  30 PRINTTAB(3,1);"ASCII Character Set 32-255"

  40

  50 FOR a=0 TO 31

  60   PRINTTAB(a+4,3);a DIV 10; TAB(a+4,4);a MOD 10

  70 NEXT

  80

  90 FOR a=0 TO 255 STEP 32

 100   PRINT;a

 110 NEXT

 120

 130 COLOUR 6

 140 FOR a=32 TO 255

 150   PRINTTAB(a MOD 32+4,a DIV 32+5);CHR$(a);

 160 NEXT

 170

 180 COLOUR 7

 190 PRINTTAB(0,14);" 32 is the code for a space."

 200 PRINT

 210 PRINT;" Zero to 31 are special control codes"

 220 PRINT" inherited from the early days e.g."

 230 PRINT

 240 PRINT"  8 = cursor back"

 250 PRINT"  9 = cursor forward (tab)"

 260 PRINT" 10 = cursor down"

 270 PRINT" 11 = cursor up"

 280 PRINT" 13 = carriage return"

 290 PRINT

 300 PRINT"Old user defined characters are very"

 310 PRINT"different to modern fonts and the two"

 320 PRINT"are not entirely compatible."

 330 END

 

Note that we can only redefine characters 32 to 255, because codes zero to 31 are reserved for special purposes.

 

 

ASCII Table: Code explained...

 

Lines 50 to 70 print the values 00 to 31 across the top of the window.

 

Lines 90 to 110 print the values 0, 32, 64, 96, 128, 160, 192, 224 vertically on the left.

 

Lines 130 to 160 change the text colour to cyan and print characters 32 to 255 split across 7 lines.

 

The remaining lines are simple PRINT statements. Note how the program ENDs and how this corresponds with the '>' character appearing in the window at the end of execution. You can enter a number of different commands via this prompt including 'RUN'.

ASCII Arrow black large Arrow black large