Project: Many host-based applications support print operations to PC-attached printers via printer emulation or print transparent mode. The Script Language supplements this with the ability to write custom print jobs using data from a host application, several host applications, PC-based files, or some combination of these. For this example, we’ll implement a print test page which demonstrates the print formatting abilities.
Algorithm: The PRINT OPEN command is used to initiate a print task, and the PRINT CLOSE command finishes the job and sends it to the printer. The PRINT FONT and PRINT STYLE commands can be used to set the print characteristics, or the printer defaults can be used. The PRINT STRING, PRINT FILE and PRINT TERMINAL commands determine the data to be sent to the printer. Optionally, the PRINT NEWLINE, PRINT NEWPAGE, and PRINT TABS commands can be used to space the print data appropriately.
Relevant Commands and Functions:
PRINT OPEN — Opens a print channel to specified printer port
PRINT CLOSE — Closes print channel, terminates any active print jobs
PRINT FONT — Changes the active print font and size
PRINT STYLE — Changes active print character attributes
PRINT STRING — Prints the specified string
PRINT NEWLINE — Sends a carriage return and line feed to printer
PRINT NEWPAGE — Sends a form feed to the printer
PRINT TERMINAL — Sends incoming session activity to printer
PRINT FILE — Prints a file
SELECTION PRINT — Prints the selected text
PRINT CANCEL — Terminates any active print jobs
PRTMETRICS( ) — Returns the current print parameters set as Windows default
PRINT TABS — Specifies print tab width
A Brief Example
PRINT FONT "Arial" 14
PRINT STYLE BOLD
PRINT STRING "PRINT TEST"
PRINT FONT "Courier New" 12
PRINT STYLE BOLD
PRINT STRING "Courier New, Bold, 12 point: 0123456789"
PRINT STYLE NORMAL
This example uses the PRINT FONT and PRINT STYLE commands to specify the size print characteristics, and the PRINT STRING command to specify the data to be printed. The PRINT STYLE NORMAL command is used to deselect bold printing. The print characteristics specified in the script are applicable only to script-initiated printing and not user-selected printing.
- The best print font size can be selected by the script according to the amount of data to be printed to the page.
- A common use of the print commands is to provide the user the ability to select data from host applications and output it in a better format.
The ADDRBOOK example allows the user to enter and organize contact info which is stored in a file, and print it out if desired.