by Thomas M. Krischan


Tired of coding all those CHR$(xx) statements to generate an EPSON printing mode? The User's Manual uses the Model I TRS-80 as its teaching system. Consequently, ATARI computer owners find, that many of the well documented examples don't work. At first glance, the EPSON printing modes seem strangely and lengthily encoded. For illustration, say we wish to print a line of double strike compressed expanded mode. We would have to type in this:

LPRINT CHR$(27); CHR$(71); CHR$(27); CHR$(70); "text"; CHR$(27); CHR$(72); CHR$(27);CHR$(69)

That accounts for 72 keystrokes dedicated for control codes. Half to enable the mode and half to disable it back. Rejoice, there is a simpler way. GRAFTRAX-80 and the ATARI computer are a great combination.

CHR$(27) is an escape code CHR$(69), CHR$(70), CHR$(71), and CHR(72) set printing modes. Each of these express a single ASCII value which just so happens to also represent a single printable screen character. Try typing this:

? CHR$(27); CHR$(27); CHR$(69); CHR$(70); CHR$(71); CHR$(72)

Aha! [ESC]EFGH. Note that [ESC] corresponds to the ESC key and that only one [ESC] is printed. The first [ESC] is used by the computer, but that's another story. Back to the printing modes. Try typing this little gem:

LPRINT "[ESC]G[ESC]Htext[ESC]H[ESC]E"

(Remember to use the ESC key twice for each [ESC] symbol).

Hey, that's the same print mode as our first illustration. And this uses only 8 keystrokes for control codes, or 12 if you're a purist and consider double presses. In either case it's much less than 72.

Before you go racing off to your printers, let's explore more about character codes, There are only 5 true character control codes (Table 1).

 

           TABLE 1.

  ON    OFF
  CODE  CODE  FUNCTION
  ----  ----  --------
   E     F    Emphasized
   G     H    Double Strike
   P     Q    Compressed
   R     S    Expanded
   4     5    Italics

We must include the necessary preceeding escape code before each of these. By specifying all possible combinations we obtain 32 character modes (2**5 = 32). These are displayed in Table 2. Note that only 24 character modes are unique. The Emphasized code (E) nullifies the Compress code (P). The first line in Table 2 was generated by:

LPRINT "[ESC]F[ESC]H[ESC]Q[ESC]S[ESC]500000FHQS5"

...where "[ESC]F[ESC]H[ESC]Q[ESC]S[ESC]5" are the necessary control codes and "00000FHQS5" is the printed text.

By the way, if you use escape codes in a program it becomes non-listable on the printer, but will list to the screen.

Now we will explore spacing codes. If you have tried the underlining example in the EPSON User's Manual you found that it doesn't space correctly with the ATARI computer. Try typing in this example:

 

10 LPRINT "[ESC]A[CTRL-E]UNDERLINE"
20 LPRINT "---------[ESC]A[CTRL-G]"
30 LPRINT "IS FAKED![ESC]A[CTRL-L]"
70 LPRINT "NORMAL LINE."
   and RUN

Let's explain how it works. Standard (i.e. default) spacing consists of 12 vertical dots or 1/6 inch. Upper case letters use the top seven dots (dots 1-7), leaving the bottom five dots blank (dots 8-12). Vertical line spacing can be changed using an ecA control code. The number following the control code signifies the number of vertical dots in a line, from 1 to 85. The ATARI keystroke which corresponds to 1 is "ctrl A", 2 is "ctrl B", etc. In our illustration we do not specify a type of vertical line spacing. The default is twelve vertical dots. The top of our line is dot #1 and the base-of our line is dot #12. Statement (10) activates the top seven pins in our printer head and we print "UNDERLINE" on dots # 1 through #7. We then change our line spacing to a five dot vertical line. In statement (20) we skip to the next printer line. Our top is now dot #6 and base is dot #17. We activate pin number four and print several dashes. Pin number four is located on dot #9. We again readjust our line spacing to a seven dot vertical line. Then, in statement (30) we skip another printer line. Our top is now dot #13 and base is dot #24. We are positioned on a standard spacing base line (i.e. 24 is divisible by 12). We then print "IS FAKED!" and reset the vertical spacing to a standard 12 dot line. Statement (40) shows us that we're back to normal.

Table 3. illustrates the five spacing codes.

 

                TABLE 3.
                
ATARI
CODE       DESCRIPTION
-----      -----------
[ESC]0     Sets 9 dot vertical line
[ESC]1     Sets 7 dot vertical line
[ESC]2     Sets 12 dot vertical line
[ESC]3 n   Sets n/3 dot vertical line
[ESC]A n   Sets n dot vertical line

Why are there so many spacing codes? Well, the first three are intended as quick and easy spacing for normal text printing. The last two codes concern more specialized text printing, like underlining and graphics.

Unfortunately, once you activate any of these spacing codes, except ec2, the printer forgets where the top, of the form is. The form feed counts the number of whole lines, not dots. You could readjust for this by manipulating with fewer or greater dots in successive print statements.

For example, in our illustration we use four LPRINT statements. But, it appears that we've only printed three lines. One of our LPRINT's is the underline. We are actually one whole line, 12 dots, behind the form feed counter. To catch up we simply add one 24 dot line, like this:

50 LPRINT "[ESC]A[CTRL-X]"

With this information in hand, EPSON printer users can write programs with much more efficient operation, not to mention the savings on keystrokes when entering programs.