|Powered by QM on a Rpi server|
KnowledgeBase 00077: Using Slave Printers
This article was originally published as a Tip of the Week.
A slave printer is one attached to the client device from which a user connects to QM via a telnet session. With terminal emulators, the slave printer can typically be selected from all printers known to the client PC rather than being restricted to one connected directly to it.
Slave Print Mode
Slave printing works by sending a control code to the terminal to enable slave print mode. When this mode is enabled, all output sent to the terminal device is actually redirected to the printer. After printing is complete, a further control code returns to normal terminal operation.
Although applications can hard code the control sequence using the CHAR() function, this reduces portability. The better approach is to use the @(-23) and @(-24) functions as the actual control code generated by these functions is set on a per-terminal type basis in the terminfo database. All of the AccuTerm specific terminfo definitions (those with the -at suffix) include these control codes.
DISPLAY 'This line appears on the screen' DISPLAY @(-23) : DISPLAY 'This appears on the slave printer' DISPLAY @(-24) : DISPLAY 'And now we are back on the screen'
Using QMBasic PRINT with a Slave Printer
As an alternative to using slave print mode as described above, using SETPTR or SET.QUEUE to set a printer into mode 5 will achieve the same effect with the same PRINT statements that would be used to direct output to a printer connected to the server.
When using printer mode 5, the data to be printed is gathered in a temporary file. When the printer is closed, either explicitly by use of PRINTER CLOSE or by return to the command processor, the data in the temporary file is sent to the terminal enclosed in the relevant control codes to direct it to the slave printer.
SETPTR 0,80,66,3,3,5 LIST SALES LPTR