All you need is 640k

Old School....When it was all BASIC :)

BASIC programming

The LPRINT command in BASIC makes output go to the printer rather than to the screen. To send text to the printer, simply enclose the words in double quotes:

LPRINT "A line of text"


The statement above will cause the printer to print the text, then move the printing position to the beginning of the next line. If you don't want this automatic carriage return and line feed, put a semicolon (;) after the data, outside the quote:

LPRINT "A line of text";

LPRINT "...and this text is on the same line"

For serial printers

If you're using your printer with a serial interface, you have to be sure to redirect output from the computer to the serial port you're using, either COM1: or COM2:, rather than to the default port, LPT1:. There are two ways to do this:


1. If you're using DOS, you can use the MODE command, as described on page 65. Then use the LPRINT command in your BASIC programs, just as we do in our examples.


2. You can also redirect output to COM1: or COM2: from within BASIC, by opening the port as a file and printing your data to that file. If you want to run any of our sample programs, you'll need to modify them. At the beginning of your program, include one of these statements:

OPEN "COM1:9600,N,8,1" AS #1

or

OPEN "COM2:9600,N,8,1" AS #1

Then, to print data, use the PRINT#1 command, being sure to include a comma between the #1 and the data:

PRINT#1,"A line of text"

Like the LPRINT command, PRINT#1 automatically moves the print position to the next line unless you use a semicolon (;) after the data.

When you send an LPRINT statement, the text between the quotation marks is converted to a string of numbers, which are then processed by the printer and output as the dot patterns that make up the individual characters. Each character is assigned a numeric value according to the American Standard Code for Information Interchange (ASCII). Since ASCII is a standard coding system, most computers, printers and other electronic devices can interpret ASCII data.

There are 256 ASCII codes. The codes from 0 to 127 are completely standardized (with a handful of minor exceptions), while those from 128 to 255 are used in a less standard way to represent a variety of special characters. The table of ASCII codes in Appendix C shows the low ASCII codes from 0 to 127.

Although most of the ASCII codes represent alphanumeric and punctuation symbols, you'll notice that the codes from 0 to 31, as well as 127, don't correspond to normal characters. These are control codes, special characters used to control a wide range of peripheral equipment, from monitors to modems to the devices that interest us here, printers.

One of the most important control codes is the ESC character, decimal 27, hexadecimal 1B. Many of the more complicated commands begin with ESC, which serves as a signal to the printer that what follows is to be interpreted as a command rather than just a string of characters to be printed.

Since the control codes don't represent any character on your keyboard, you can't send them to the printer enclosed in double quotes, as you would with text. Instead, you have to use the CHR$ function, which lets you send the decimal or hexadecimal value for a character. For example, the escape character is represented as CHR$(27), or, in hexadecimal, as CHR$(&H1B). (Notice that hexadecimal numbers in BASIC are preceded by &H to distinguish them from simple letters or decimal numbers.)

Of course, you can also use the CHR$ function to output printable characters; for instance, CHR$(65) represents the letter A. However, it's usually easier to type letters, numbers and punctuation marks, and your BASIC programs will be much easier to read if you use literal characters, enclosed in quotes, wherever possible.

Some printer commands expect you to supply a numeric value representing tab stops, line spacing, etc. These values can be entered by using the CHR$ function.

Graphics

One of the strengths of dot matrix printer technology is the flexibility that comes from printing patterns of dots. If you can control where the dots are printed, you can print almost any kind of graphic image. If you look closely at a photo in a newspaper, you'll notice that it's made up of thousands of tiny dots. You can use your ML380 printer to print similar dot graphics.

Your ML380 printhead has two columns of 12 pins, for a total of 24 pins. Images are created as the pins "fire", striking the ribbon against the paper to produce dots. White spaces appear where the pins don't fire.

要查看或添加评论,请登录

The Maya Solutions的更多文章

社区洞察

其他会员也浏览了