Examples (PRINT EJECT command)
Displaying Column Headings on the First Output Page Only
DO IF $CASENUM EQ 1.
PRINT EJECT /' NAME ' 1 'DEPT' 25 'HIRED' 30 ' SALARY' 35.
END IF.
PRINT / NAME DEPT *
MOHIRED(T30,F2) '/' YRHIRED *
SALARY (T35,DOLLAR8).
EXECUTE.
-
PRINT EJECT
specifies strings to be used as column headings and causes a page ejection.DO IF-END IF
causes thePRINT EJECT
command to be executed only once, when the system variable $CASENUM equals 1 (the value that is assigned to the first case in the file). Thus, column headings are displayed on the first page of the output only. The next example shows how to display column headings at the top of every page of the output. - If a
PRINT
command were used in place ofPRINT EJECT
, the column headings would begin immediately after the command printback.
Displaying Column Headings on Each Output Page
DO IF MOD($CASENUM,50) = 1.
PRINT EJECT OUTFILE='/mydir/out.txt' /' NAME ' 1 'DEPT' 25 'HIRED' 30 ' SALARY' 35.
END IF.
PRINT OUTFILE='/mydir/out.txt' / NAME DEPT *
MOHIRED 30-31 '/' YRHIRED *
SALARY 35-42(DOLLAR).
EXECUTE.
- In this example,
DO IF
specifies thatPRINT EJECT
is executed ifMOD
(the remainder) of $CASENUM divided by 50 equals 1 (see Arithmetic Functions for information about theMOD
function). Thus, column headings are displayed on a new page after every 50th case. - If
PRINT
were used instead ofPRINT EJECT
, column headings would be displayed after every 50th case but would not appear at the top of a new page. - Both
PRINT EJECT
andPRINT
specify the same file for the output. If theOUTFILE
subcommands onPRINT EJECT
andPRINT
do not specify the same file, the column headings and the displayed values end up in different files.