Star Micronics NX-15 user manual Control codes, 10 ‘ Demo of ASCII code 20 LPRINTCHR$7 30 END RUN

Models: NX-15

1 210
Download 210 pages 57.72 Kb
Page 47
Image 47
■Control codes

39

Taken together, these numbers and their meanings make up the ASCII code (pronounced ask-key), which stands for the American Standard Codefor Information Interchange. There are ASCII codes for all the letters of the alphabet (upper case and lower case), Oto 9, most punctuation marks, and some (but not all) of the functions of the printer.

There are a number of different ways to represent an ASCII code, depending on how you are using it. For example, the ASCII codes for the upper-case letter “A” are 65 (decimal) or &H41 (hexadecimal). Or you can just call it “A”. Appendix B shows all of the ASCII codes.

BASIC uses the CHR$ function to represent ASCII characters and many functions. To print the letter “A” we would enter LPRINT CHR$(65). To make the printer’s bell sound, we would enter LPRINT CHR$(7). In general, we print a character by entering LPRINT CHR$(ASCII code) to the printer.

We can also use hex ASCII codes. Although we use only decimal ASCII codes in this manual, in some applications it will help if you understand what a hex code is. “Hex” is short for hex- adecimal and refers to a base-16 number (the numbers we use in everyday life are base 10). Since the hex system needs 16 digits, it uses the numerals Othrough 9 and also the letters A through F. In BASIC programs, you can always tell that a number is in hexadecimal by the “&H” immediately preceding it. The ASCII code for the letter “A” (65 in decimal) is &H41 in hex.

Control codes

ASCII codes with values of 32 or less do not correspond to keys on the keyboard. These codes control many of the printer’s functions, so we call them control codes. To enter a control code from the keyboard, we have to press two keys at the same time

the “control” key and one other. The other key determines what code is sent – pressing the control (CTRL) key and A sends ASCII code 1, CTRL B sends ASCII code 2, and so on.

Your printer has a lot of control codes to let you do some useful things. Let’s try one that we’ve mentioned several times already:

10‘ Demo of ASCII code

20 LPRINTCHR$(7)

30END

RUN

Page 47
Image 47
Star Micronics NX-15 user manual Control codes, 10 ‘ Demo of ASCII code 20 LPRINTCHR$7 30 END RUN