Star Micronics NP-IO manual

Page 27

nASCII codes and the CHR$ function

You can talk to your computer in BASIC, but your computer and your printer talk to each other in what are known as ASCII codes. In the ASCII code, each number from 0 to 255 has a par- ticular meaning - 36, for example, makes the printer print a dollar sign. Some numbers cause the printer to do other things, too. For instance, sending a 7 sounds the printer’s bell.

Taken together, these numbers and their meanings make up the ASCII code (pronounced ask-lzey), which stands for the American Standard Code for Information Interchange. There are ASCII codes for all the letters of the alphabet (upper case and lower case), 0 to 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 0 through 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.

nControl 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

Image 27
Contents NP-IO Self Declaration Table of Contents BIG Caring for Your Printer Functions of the Connector Signals Setting UP Your Printer Page Remove the protective tube from the carriage rail Page ‘.igure Memo Getting to Know Your Printer Pow\er cord Control panel Forward Selecting and Loading Paper Release lever To align paper that is not in straight Release lever Open the sprocket covers to expose the sprocket teeth Adjusting the Print Head Show you Printer When Want to Long Function Connecting the Printer Printing with Basic List Page Ascii Page Some Special Kinds of Text ESC Italic on Try this program to see them work Pica ESC P Elite Escm When you run this program you should get this Lprint Condensed CondensedON Here’s what you should get from this program Making Words Stand OUT Boldface on =49 Summary notes Formatting Text Line feed commands This is what you will get Run the program again. Now the results will look like this Set line spacing Inch Esco Set line snacing Lprint Line Number Form feed Lprint CHR$ ESC Top and bottom margin commands Function Control code Lprint this is LINE1 Next Page Try setting the margins with this program Here’s what you should get To begin Try this program to see how this works Lprint CHR$27xO 110 END Relative Horizontal Tab Lprint CHR$27BCHR$lOCHR$l5 Lprint CHR$25CHR$30CHR$o Lprint CHR$llFIFTH TAB CHR$n When you run this program the printout should look like this When you run this program, you should get like this Memo Special Features Printer Lprint CHR$7 Master rest Lprint Backspace does not Lprint CHRS27il Added Spaces This Lprint Next Lprint Lprint Eighth bit controls Next J Page Lprint CHR$27 Lprint CHR$27= Lieltil~l When you refer the Appendix C, you’ll find many characters When you run this program you should get like this Big character commands Function Lprint Double CHR$SO Lprint Testing Abcd ~~III.II I I,I~I~II L 1-t40 Memo Download Characters DOT Graphics Pins prints a row of dots Vertical 241 P r ESC 8~ CHR$O nl n2 m0 ml m2 m3 m4 m5 m6 m7 m8 m9 ml0 ml1 Page Lprint U.S. Exports Lprint Scales Designing Your OWN NLQ Characters Page Lprint Lprint CHEMICALSCHR$9 Lprint CHR$9i--I SCALE$=--+-I For I=2 to 8 Step Calculating Nl and n2 Umber of col- 1 Then nl is N2 is 11m2 More graphics commands Printer needs 2 bytes to fire all 9 pins in the g-pin