Copyright (c) Hyperion Entertainment and contributors.

AmigaOS Manual: Printing

From AmigaOS Documentation Wiki
Revision as of 00:01, 22 September 2017 by Janne Peräaho (talk | contribs)
Jump to navigation Jump to search

A printer configured in the Printer Preferences can be used for printing ANSI text and text files. Depending on the selected printer driver, you can print with a parallel port printer or an USB printer (usbprinter.device) or print to a file (printtofile.device). Printing graphics is not supported.

Printing is done using the PRT: device. The printing procedure is as follows:

  1. Open the PRT: device for writing.
  2. Write the text to be printed to the device.
  3. Close the device.

By default the PRT: device processes ANSI sequences before sending the text to the printer. This can be changed. When opening the device, it can be instructed to not substitute any ANSI sequences or to just turn the carriage return translation off.

While opening the PRT: device the following keywords are available:

Keyword Template Description
RAW RAW/S Switch for turning carriage return translation off.
TRANSPARENT TRANSPARENT/S Switch for disabling carriage return translation and ANSI sequence substitution.
UNIT UNIT/K/N Numeric argument telling which printer device unit should be used. The default unit is 0.

Parameters are separated with /. For example to open a PRT: device unit 0 and disable translation and substitution:

OPEN( 'printer', 'PRT:TRANSPARENT/UNIT=0', 'W' )

Program 18. PrintTestPage.rexx

/*
** Print a test page
*/
 
/* Get date and time */
createdDate = TIME() || ' ' || DATE()
 
/* Set page width (characters) */
pageWidth = 69
 
/* Use printer unit 0 */
printerUnit = 0
 
/*--- Open printer ---*/
IF ( ~OPEN( 'printer', 'PRT:UNIT=' || printerUnit, 'W' ) ) THEN DO
    SAY 'Cannot connect to the printer.'
    EXIT 0
END
 
/* Compose title */
titleL = 'Line Mode Printing Test Page'
titleR = RIGHT( 'AmigaOS 4', pageWidth )
title  = OVERLAY( titleL, titleR )
 
/* Compose character set */
charset = XRANGE( ' ', '/') || XRANGE( ':', '@' )
charset = charset || XRANGE( '[', '`' ) || XRANGE( '{', '~' )
charset = charset || XRANGE( '0', '9' )
charset = charset || XRANGE( 'A', 'Z' ) || XRANGE( 'a', 'z' )
 
/* Separator line */
separator = COPIES( '-', pageWidth )
 
/*--- Print test page ---*/
WRITELN( 'printer', title )
WRITELN( 'printer', '' )
WRITELN( 'printer', separator )
WRITELN( 'printer', '' )
DO WHILE ( LENGTH( charset ) > 0 )
    PARSE VAR charset out +pageWidth charset
    WRITELN( 'printer', out )
END
WRITELN( 'printer', '' )
WRITELN( 'printer', separator )
WRITELN( 'printer', '' )
WRITELN( 'printer', 'Page width: ' || pageWidth || ' characters' )
WRITELN( 'printer', 'Printer: Workbench printer (SYS:Prefs/Printer)' )
WRITELN( 'printer', 'Created at: ' || createdDate )
WRITELN( 'printer', 'Printed at: ' || TIME() || ' ' || DATE() )
 
/*--- Close printer ---*/
CLOSE( 'printer' )