Classic Computer Magazine Archive COMPUTE! ISSUE 71 / APRIL 1986 / PAGE 10

Readers Feedback

The Editors and Readers of COMPUTE!



Simpler Absent Printer Test
I'm writing with regard to the "Readers' Feedback" item on absent Commodore printers, published in the December 1985 COMPUTE!. Another way to avoid a DEVICE NOT PRESENT error is to access the appropriate device (4) through the command channel (15) and check the value of the status variable ST. If ST does not equal 0, then the printer is not present. Here is a short routine to demonstrate:

10 OPEN 15,4,15:CLOSE 15
20 IF ST<>0 THEN 40
30 OPEN 1,4:PRINT#1,"PRINTER I
       S ON":CLOSE 1 :END
40 PRINT CHR$(147);"TURN ON PR
       INTER":GOTO 10

    If you run this program with the printer off, it instructs you to turn the device on. Printing begins as soon as the printer is active.
Jim Plavecsky

Thanks for this compact, all-BASIC solution. In programs that open disk files or use an RS-232 device (usually a modem), you may want to perform this check at the very beginning, before you perform any other OPEN statements. The statement CLOSE 15 closes all other channels in addition to the command channel, terminating any RS-232 communications and disconnecting (but not really closing) any open disk files.