<LET P=o> takes care of “sending LPRINT character streams” to a Centronics printer. The other half is sending “Printer Control Codes” to command the printer to do such things as change type fonts, set italic, and set underline modes. Most printers have a group of dip switches to manually set these functions, but ususually the dip switch panel is located in a difficult to reach area. What is needed is “software control”. Lets explore how to build a software “printer control group”. First, a MENU is needed. The menu would look something like the following:
1. Pica Style 2. Elite Style. 3. Condensed Style. 4. Italic Font. 5. Underline.
When the menu is presented, a touch of key 1-5 should set a variable to the value of the key touched. See the INKEY$ prompt routine in this issue. We will let the variable “ps” be our switch. After the menu and the INKEY$ prompt, this program line will do it: <900 LET ps=z>. For example; if Key 1 is touched, Pica style is selected and “ps=1”. Before continuing, you should make sure that the printer actually responds to a LPRINT command. Type <LPRINT “12345” ENTER”. If 12345 is printed to paper you may proceed. If not, then you must set up the printer correctly before proceeding.
Now, assuming that a menu has been constructed, we will build a printer control group. LINE 900: <900 LET ps=z: GO TO 1000>
Line 1000 should contain the programming needed to CANCELL all special printer set-ups to make ready for commands to establish the print styles selected at menu. Some printers have a single command code to do this, BUT many printers will also RESET TOP OF FORM when the RESET command is used. That would disturb a page format after a print style change has been directed. Line 1000 should contain groups of CANCEL commands for every conceivable printer set-up, WITHOUT resetting TOP of FORM. Then you’ll be ready to set the print style selected at menu.
Before going to the next lines, we will discuss how control codes are sent to a printer. Lets use a typical control code group as would be given in a printer manual. (27,100) (80,102). To send such a group, this programming would be needed: <line GO SUB BU: OUT 127,27: GO SUB BU: OUT 127,100: GO SUB BU: OUT 127,80: GO SUB BU: OUT 127,102 >. Explanation: <OUT 127> sends the control code to the printer, BUT- the printer must be READY to receive a control code. <GO SUB BU> is a line to assure PRINTER READY>. We will now construct “line BU as line 2000. <2000 IF IN 127<>253 THEN GO TO BU> <2002 RETURN>.
To explain the above: When a printer is READY to receive a control code, <IN 127> produces character code 237. If NOT READY, <IN 127> produces the character code 253. So, line BU (2000) will loop itself until the printer is READY. Now, using the examples given, line 1000 can be constructed: <1000 GO SUB bu: OUT 127,27: GO SUB bu: OUT 127——continue all control codes needed to CANCEL ALL printer set-ups—>. Refer to your printer manual for the correct control codes.
Next, <IF THEN programming is needed to set the print styles selected at menu. Typically, these would be:
<1002 IF ps=1 THEN GO SUB BU: OUT 127,——the printer control codes needed to set pica style. Use GO SUB BU between each.>
<1004 IF ps=2 THEN GO SUB BU: OUT 127,—–the command codes needed to set ELITE style. Use GO SUB BU between each OUT 127 command.>.
Continue building program lines as above for commanding the printer to set the other menu selections. When finished, the last line should be <line GO TO the line of your major menu>. Try out the “print style menu” and the program lines that have been constructed. Chances are that the print style changes selected at menu WILL be made at the printer, BUT, extraneous line feeds will occur. If so, check the printer manual to find the “Cancel Buffer” control code. Usually this is character code 24, but some printers use an extra command code. To eliminate extraneous line feeds, the Cancel Buffer code is inserted after each group of control codes for a special function. Dont forget to use <GO SUB BU> between each OUT 127 command.