Printing

From Recital Documentation Wiki
Jump to: navigation, search

The printing commands within the Recital/4GL allow you to send output to a system printer, to a file or to a local printer attached to the printer port of your terminal.


See Also

?, ??, ???, @...SAY, Configuration Files, DB_PRINTEREJECT, DB_PRINTERROR, EJECT, GETENV(), PCOL(), PRINT, PRINTFILE(), PRINTSCREEN(), PROW(), PUTENV(), SET CONSOLE, SET DEVICE, SET MAPCHAR, SET PRINT, SET PRINTER, SET SCREENMAP, SETPRC(), SYS(), Terminal Definition Files


Printing to a System Printer

When you have a default printer destination set on your system, the following command will send the specified file to that printer:


print <filename>


To redirect output to a system printer, the command [SET PRINTER|SET PRINTER TO \\SPOOLER]] is used. This picks up the environment variable DB_PRINT (set in the system-wide configuration file). The value of DB_PRINT must be either a valid Operating System print command, e.g. on UNIX:


DB_PRINT="lp -dmyprinter -onobanner"


or the name of a file which contains such a command (and any other processing required.) By default, DB_PRINT is set to the file ’print.<os>’ in the Recital home bin sub-directory. This can be modified if required, to suit your particular printing environment. The ’print.<os>’ file contains a further environment variable, called DB_PRINTOPT, which can be set to the options that you require on the OS print command. By default, the value of DB_PRINTOPT is set in the system-wide configuration file, but the PUTENV() function can be used to change this value, and the GETENV() function to query it. The following commands will cause an environment status listing to be printed according to the command(s) specified by DB_PRINT:


set printer to spooler
list status to print
set printer to


The following will send output to the system printer (and the screen):


set printer to spooler
set print on
&& ...output
set print off
set printer to


Stopping Output to the Screen

To send output solely to the specified printer, and not to the screen, the following commands are required:


set screenmap off
set console off
set device to print


And to return control to the screen:


set device to screen
set console on
set screenmap on


Printing to a File

For printing to a file, the same commands apply, but you should specify the filename in the SET PRINTER command:


set printer to myfile.txt
list memory to print
set printer to


Printing to a Slave Printer

If you have a printer attached to the printer port of your terminal or PC, the SET PRINTER command is not required. Use the SET PRINT command to redirect output to the printer. To prevent output also being sent to the screen, use the commands as listed above. To switch your terminal output to screen / printer or printer only mode, the control sequences specified in entries 4, 5 and 6 of the Terminal Definition File are used.


// Program to send display to local printer
set screenmap off
set console off
set device to print
set print on
@1,1 say [hello world!]
set print off
set device to screen
set console on
set screenmap on


Sending Control Sequences

Control sequences can be sent to your printer using the ? or ?? commands. The command SET SCREENMAP OFF must be issued before sending the sequences to prevent them being re-mapped, e.g.


// Program sending control sequences and text to a file
set printer to myfile.txt
set screenmap off
set console off
set print on
 
// Switch into ’emphasis mode’
? CHR(27) + "E"
?? [HELLO]
// Switch out of ’emphasis mode’
? CHR(27) + "F"
?
? [HELLO AGAIN]
set printer to
set print off
set console on
set screenmap on


Control sequences sent must be appropriate to your printer.


PRINTSCREEN()

The PRINTSCREEN() function can be used to dump a copy of the current screen to a file or to a system printer (not slave). The function is most often called from within a hot key procedure to enable screen dumps of full screen forms, e.g.


// Hot key procedure
procedure pscreen
set printer to spooler
printscreen()
set printer to
return
 
// Current screen is sent to system printer when [TAB] key is pressed
on key label tab do pscreen