Guardian Programmer's Guide

Table Of Contents
Communicating With Printers
Guardian Programmer’s Guide 421922-014
11 - 40
Sample Program for Using a Printer
!------------------------------------------------------------
! Procedure for printing records. The user selected "p."
! The procedure prints out the entire file, six records
! to a page.
!------------------------------------------------------------
PROC PRINT^FILE;
BEGIN
STRING .PRINTER^NAME[0:MAXFLEN];
INT PRINTERNUM;
INT PLEN;
INT ERROR;
LITERAL EXCLUSIVE = 1;
LITERAL POSITION = 1;
LITERAL TOP^OF^FORM = 0;
! Open the printer with exclusive access, using the OUT file
! from the Startup message:
ERROR := OLDFILENAME_TO_FILENAME_(
CI^STARTUP.OUTFILE.VOLUME,
PRINTER^NAME:MAXFLEN,
PLEN);
IF ERROR <> 0 THEN CALL PROCESS_STOP_(!process^handle!,
!specifier!,
ABEND);
ERROR := FILE_OPEN_(PRINTER^NAME:PLEN,PRINTERNUM,
!access!,
EXCLUSIVE);
IF ERROR <> 0
THEN CALL FILE^ERRORS^NAME(PRINTER^NAME:PLEN,ERROR);
! Position paper to top of form:
CALL CONTROL(PRINTERNUM,POSITION,TOP^OF^FORM);
IF <> THEN CALL FILE^ERRORS(PRINTERNUM);
! Position to the start of the parts file:
SBUFFER ':=' "0";
CALL KEYPOSITION(PARTFILE^NUM,SBUFFER,
!key^specifier!,
1,0);
IF <> THEN CALL FILE^ERRORS(PARTFILE^NUM);
! Loop until all records printed:
WHILE 1 DO
BEGIN