The monadic system function
⎕HC is used to write hard copy to an output device, usually a printer. The exact implementation of
⎕HC depends on the system on which APLX is implemented.
For Server editions of APLX, up to 9 logical printers may be available. These are defined using the Configure Printer option of the File.. Print.. menu, or may be pre-defined in a resource file. Each logical printer defines the spool queue and type of printer to be used.
Once printers have been set up, they can be used through the Print menu, or through
⎕HC printing, all output to the screen is also sent to the printer, unless screen printing has been switched off using
In APLX for Windows and APLX for MacOS, the operation of
⎕HC is similar except that printing always takes place to the currently-selected printer, i.e. the printer last selected using the Print Setup dialog. (You can display this dialog under APL program control using the 'Printer' object class in
⎕WI, which also provides alternative and more flexible printing facilities). Thus, only printer 1 can be selected using
⎕HC, even though there may be more printers potentially available via the dialog.
The syntax of
RESULT ← ⎕HC CODE
where CODE defines the operation you want to carry out, and RESULT is usually an error code (see below). 0 always means successful operation.
⎕HC Function Codes
1 to 9 Switch on printing to printer number 1 to 9 inclusive
(only printer 1 valid under MacOS and Windows)
¯1 to ¯9 Keep the specified spool file open, but do not write to it.
This option is useful if you want to ask for input, or display
progress messages which you do not want to print.
0 Switch off printing, submit the spool file to the
1000 Suppress screen output, but continue to write to the spool file.
This option is useful if you want APL output to be printed, but not
appear on the screen. This option is valid only if printing is
on. Screen output is reset automatically by ⎕HC 0.
¯1000 End suppression of screen output.
99 Return the current value of ⎕HC. In this case, the
result is not an error code, but a printer number
1 to 9 (or ¯1 to ¯9), or 0 if printing is not on.
The following codes are valid for Server editions of APLX only:
100,200... Open spool file (append if it exists), but don't
automatically submit on Quad-HC 0. 100 is Printer 1,
200 is Printer 2, etc.
101,201... Submit spool file opened with 100, 200 etc, then delete.
102,202... Submit but don't delete.
103,203... Delete spool file opened with 100, 200...
⎕HC Return Codes
0 Operation successful
1 Invalid command or printer not defined
2 Printer not accessible
3 I/O error or disc full
4 ⎕HC 1000 requested, but printing not on