Classic Computer Magazine Archive CREATIVE COMPUTING VOL. 9, NO. 10 / OCTOBER 1983 / PAGE 306

IBM images. (on using the NEC 8023A printer) (column) Susan Glinert-Cole.

The column is a bit terser this month, as we have been occupied with moving to warmer parts of the country. There is a subtle irony behind this upheaval, which may be gently described as Will Fastie's idea of a final revenge. As I Am now working for him, it remains to be seen to whom the final revenge will be awarded.

The computer will enjoy the freedom from woodsmoke (as will the rest of us). I have been mildly insistent, at the top of my lungs, about the next house having absolutely to flue, chimney, thimble, fireplace, woodstove, or any object which needs to bed fed every few hours with things which deposit bark particles and confused ants to the floor.

For the first time in years I can look forward to October weekends.

Hitherto they have been occupied with standing on top of ten cords of renewable resource with a 16" chainsaw or staggering under a load of same renewable resource on the way to the barn. Now you know why I don't have any energy left over to swap disks. I am hoping that a more benevolent climate will leave me with enough vibor to cope with a three pass compiler. More on the NEC 8023A

There has been so much mail about the NEC 8023A printer the past few months that it is time I responded in a more constructive manner than that of putting the letters carefully away in the filing cabinet. First, there is the matter of printer ink. The suggestion regarding the use of stamp pad ink to rejuvenate the cartridge rollers drew gasps of horror from a few people.

The maintain that stamp pad ink does not contain the proper lubricants for dot matrix printheads and would therefore do much damage if used. This may ver well be true; I am not by any means an expert in the area. I used the stamp pad ink approach for about eight months, and my printer has not appeared to suffer from this abuse.

For the wary, however, ink of the proper quality for dot matrix ribbons may be ordered from Ben Torres Ribbon Service. An alternative to constantly reinking ribbons is to squirt the ribbon with WD-40 and allow the ribbon to dry for a few hours with the cover off.

I tried this about a year ago before I discovered stamp pad ink and it works well on a one-time only basis. The next ribbon drenching ceremony should feature some sort ink, as the WD-40 is merely a one-shot rejuvenator.

Next, the mystery of the Ctrl + PrtSc command was solved by several people. Switch 1-7 should be set to the ON (closed) position. The PrtSc function will work perfectly, and other printed files, such as Basic listings and word processor printouts, will not have the extra linefeed (see below).

The manual that came with my printer was not exactly a prototype of limpid prose. I think it was written in Japanese and then translated, word by word, into English. The fact that all the examples are for the NEC personal computer didn't help either. For the record, then, here are the functions reserved for the two DIP swtiches.

Switches 1-1, 1-2, and 1-3 are used to select the appropriate character set, depending on which country you are presently residing in (or feel like writing in). If they are all off, the Japanese character set is selected; the correct setting for the United States is OFF ON OFF respectively.

If the British character set is selected by setting Switch 1-1 ON, the # sign on the keyboard becomes the [pound] sign. Setting the switches as described in the manual for the German and Swedish character sets will sprinkle umlauts throughout the text.

A table in the back of the manual shows the replacement characters applicable to each character set. Switch 1-4 determines how many lines are on a page for the Top of Form character. The default setting is OFF for 66 lines; if you prefer legal sized paper, setting it ON will set 72 lines per page as the default.

Switch 1-5 should be OFF. This allows you to select or deselect the printer from the keyboard or a program by sending a CHR$(17) for select or a CHR$(19) for deselect. These signals are equivalent to pressing the SELECT switch on the front of the printer.

If this switch is turned ON, these characters will be ignored by the NEC.

Switches 1-6, 1-7, and 1-8 determine what happens at the end of a print line. The factory settings are: ON OFF OFF respectively. Ctrl + PrtSc will have the effect of printing everything on one line, although output from my word processor is correct. As stated above, setting Switch 1-7 ON will correct this problem.

For the curious, the various permutations are:

OFF OFF OFF: Inserts an extra carriage return/linefeed; word processor output is double spaced but PrtSc is correct.

OFF ON OFF: Both the word processor and PrtSc do a correct page print.

OFF ON ON: Extra carriage Return/linefeed inserted in both PrtSc and other output.

ON OFF OFF: PrtSc prints on one line but word processor output is correct.

ON OFF ON: Extra carriage return/linefeed in word processor output, but PrtSc is correct.

ON ON OFF: Both PrTSc and other output are correct.

ON ON ON: Extra carriage return/linefeed in both PrtSc and other output.

Swtich 2-1 determines whether you have a slash through the zero. This is a matter of taste; if you are a slasher, set Switch 2-1 ON. Switches 2-2, 2-3, and 2-4 are particularly useful if more than one printer is being driven from the same port and you wish to send information to a specific device. Normally, Switch 2-2 is OFF; turning it ON assigns each printer a device address as determine by Switches 2-3 and 2.4.

Since two switches are allotted to address specification, up to four (two squared) devices may be used in this manner. An address is enabled with Esc + a-d, where a device 0, b is device 1, and so on. When using this mode, the printer(s) must be on-line, that is, the SELECT light must be lit. The appropriate escape code as described above will then activate the designated device.

Switch 2-5 determines the default typeface when the printer is turned on. The default (OFF) is pica; proportional printing is selected if 2-5 is turned on. Switch 2-6 selects 7- or 8-bit data. This should be OFF (8-bit) for the IBM. Switch 2-7 deterimes whether the printer is in the selected state at powerup (e.g. puts the printer on-line). This should be ON, for select. The factory setting is OFF, which means you have to press the SELECT switch every time you turn on the printer, something you may not remember to do or want to be bothered with. Printer Formatting Program

Several months ago I promised a Basic version of the printer formatting program which originally appeared in USCD Pascal. Wait no longer. Here it is in two different versions. The fundamental premise, as in the original, is to conveniently send codes to the printer from inside of a file to make the output look resplendent, exotic, or what have you. The first (Listing 1), short program is very simple, and can be easily adapted to any other printer by simply changing the codes in the lines 4700-6000. Other, more elaborate functions can also be added--horizontal and vertical tabs for example. The program is organized in a manner commensurate with customization. Options such as double spacing or page number subroutines can be worked in around lines 840-940.

Somewhere around lines 4000-4600 I intend to insert a routine each which will recognize the REM string and print these lines in the different typeface for added readability in a program listing. This version of the program was deliberately kept short and moderately generic so that other printers may be accommodated too.

Line 545 deserves some comment. When I wrote the program, I originally used the command LPRINT to send all codes to the printer. This resulted in an extra linefeed being inserted after every line of the file. It took me a while to find the cause of this, because the Basic manual misspoke on the subject.

It claims that Basic will send an extra carriage return/linefeed after printing 80 characters unless the statement is ended with a semicolon.

In fact, Basic seems to print the extra cr/lf pair regardless; it blithely ignored the semicolons and casually double spaced everything anyway. Specifying a WIDTH: "LPT1:", 255 will disable line folding. In the interest of generality, the final version opens "LPT1:" as a file and printing the character codes to it. This allows the output to be directed to any file (disk, communications, and so on) by changing "LPT1:" to the desired file name.

The program takes each character in the specified file and checks to see if it is the start of a printer command. If so, the program goes to a routine which reads the code sequence into CODES$ and then sends it to the printer.

The printer commands are recognized by square brackets ([ ]), but these may be changed in lines 1080 and 4080. If your preference, for example, is to put the commands on separate lines, make the termination character a carriage return (CHR$(13)).

The WAIT statement in line 6900 is a very useful command. Many routines which deal with printer errors simply make the computer do some mindless arithmetic while the operator is supposed to be turning on the printer. This is not very elegant, and, as you might have suspected by now, there is a better way.

The improved method instructs the computer to twiddle its thumbs until it receives a SELECT signal from the printer. The trick is implementing the WAIT was to locate both the proper port number of poll and the correct series of bits which would be recognized as the SELECT signal. This information can be found by a close reading of pages 2-72 and 2-73 in the Technical Reference Manual. The SELECT signal travels on pin 13 of the printer adapter connector via port (address) 378H.

There are, as usual, eight bits sent to the computer in this byte and we are interested in having the computer wait around until pin 13 becomes active (ON or 1). The signal byte we wait for therefore looks like Figure 1.

Those of you who took last month's column to heart will instantly recognize 00010000 as 2, or 32 decimal. Line 6900 thus specifies that the computer wait until 00010000 appears at port 379H. (Note: if there is an IBM monochrome display/printer adapter board in use, the correct address is 3BDH).

There appeared, from the letters I received, to be some confusion about the printer codes themselves. One problem is that some of the codes must be prefaced by an escape character (CHR$(27)), while others may not be so preceded. This is manifested, for example, with the double wide typeface: this is invoked with CHR$(14) with no escape code. Similarly, the Top of Form character (CHR$(12)) must travel alone. The documentation does not make this terribly clear, but there it is. Lines 4700-6000 present all the codes for typefaces and line spacing for the NEC. The Long Form

The second (Listing 2), long version of this formatter has some extremely pleasant features added to it, and it should be emphasized again that both of those programs lend themselves to customization to other printers and even other computers (heaven forbid).

With this program it is possible to take full advantage of the extended character set that the NEC 8023A provides. This printer will print, for example, all digits from 0 to 9 as superscripts. It is therefore possible, in theory, to print attractive mathematical formulas.

The problem is always that what you see on the display is not necessarily what is printed to the printer; this can add extra confusion to an already complicated output line. In this program, a number to be superscripted is preceded by a tilde (CHR$(126)). Being able to view the number to be superscripted makes it much easier to proofread a page of formulas on the screen and is obviously more meaningful than random, unusual characters. Because the program allows superscripts of any size, it can also be used for simple footnoting.

I have long been bothered by the fact that the IBM and the NEC printer have completely different assignments for the extended character set, so even if there are characters common to both sets, it is difficult to do things like design forms on the display. This problem is addressed in the long version of the formatting program, which will correctly translate on-screen characters to the corresponding NEC extended ASCII code.

The translating table works perfectly for characters that are identical (Greek letters and some math symbols for example). There are characters which are found in the IBM set which must be composed from symbols in the NEC set--some of the graphic symbols and foreign letters for example. This was done by working out the sequence of character codes for the composed symbol. The character e is made up of three character codes: CHR$(101) for the e, a CHR$(8) for the backspace, and CHR$(44) for the accent mark.

Some characters in the IBM set cannot be done with the NEC, but surprisingly, most of them can be built with a little twiddling. In some cases, the composed character is not exactly equivalent, and you may prefer some other representation than the one output by this program.

The translating table is set up as a 127 X 4 array and can thus contain codes for 127 characters composed of up to four keystrokes each. If a character code greater than ASCII 127 is found in the file, the program routes to the conversion routine in line 12000.

Since it isn't possible to have the array begin with a subscript of 128, the first line of the subroutine subtracts 127 from the ASCII code value to find the corresponding row. Thus the character e, which in IBM ASCII is CHR$(130), is found in row 3. The DATA statement on line 15050, will, if carefully dissected by fours, will show the third set of data to be 131, 8, 39, 0. The routine then prints all these characters to the printer and, voila, what you see when you enter an e in your file is actually what you get on the printer. For those characters for which there was no hope of possible correspondence between the NEC and the IBM, the data table simply contains four zeroes; you can make up your own characters and insert them as you please. Naturally, if you own a different printer, you will have to produce a different data table but the principle still applies.

One note with this program: the NEC will only recognize a backspace character when in the incremental mode (the default is the logic seeking mode). This means that instead of seeking the shortest distance to the next character, the printheat automatically returns to the lefthand margin after receiving a carriage return. Printing is therefore unidirectional and it takes about twice as long as usual to print out a file.

If your do not intend to use any of the composed characters which contain a backspace and prefer a more energetic printing pace, remove line 553. The program, by the way, has not been optimized for speed in any way and I suggest that some care be taken if you intend to use it. In its present condition, with all the REM statements and long variable names, it takes forever to initialize. Vertical Tabbing

Another peculiarity of the NEC was brought to my attention by John Widman. The vertical form unit (VFU), which allows vertical tabbing for printing forms, will not load correctly unless the propensity of Basic to add the extra lf/cr after 80 characters is defeated with the following statement:

WIDTH "LPT1:", 255

I know, I promised something on the 8087 and the p-system this month but what with the packing and yard sales and all of the other details that go into relocation, not to mention the new game from Funtastic, there just wasn't time to do that too. Next month for almost sure and while I am on the subject of next month, if there are topics you would like to see in this column, please let me know.

I have been trying to strike a balance between reviews and more generally applicable topics, while still addressing less recognized systems. This philosophy is intended to enlighten the novice, but keep the more advanced user attentive. An excoriating or approving letter will let me know if the novices are bewildered and the rest of the audience fast asleep.