Output Option

<output option>

──┬─<file designator>──┬───────────────────────────────────────────────┤
  └─<output procedure>─┘

<output procedure>

──<procedure identifier>───────────────────────────────────────────────┤

If a file designator is specified as the output option, the sort intrinsic writes the sorted output to this file. When sorting is completed, the sort intrinsic closes the file. If the file is a disk file for which the file attribute SAVEFACTOR has a nonzero value, it is closed and locked. The output file must not be open when it is passed to the sort intrinsic by the program.

If an output procedure is specified as the output option, the sort intrinsic calls the output procedure once for each sorted record and once to allow end-of-output action. This procedure must be untyped, must not be declared EXTERNAL, and must have two parameters. The first parameter must be a call-by-value Boolean variable, and the second parameter must be a one-dimensional array with a lower bound of zero. The Boolean parameter is FALSE as long as the second parameter contains a sorted record. When all records are returned, the first parameter is TRUE and the second parameter must not be accessed. The output procedure must not contain any SORT or MERGE statement.

The following is an example of an output procedure:

PROCEDURE OUTPROC(B,A);
VALUE B;
BOOLEAN B;
ARRAY A[0];
   BEGIN
   IF B THEN
      CLOSE(FILEID,PURGE)
   ELSE
      WRITE(FILEID,RECSIZE,A[*]);
   END OUTPROC;