Input Option

<input option>

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

<input procedure>

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

If a file designator is used as the input option, the file supplies input records to the sort intrinsic. This file is closed after the last record is read. Disk files are closed with regular close action, and nondisk files are closed with release action. The input file must not be open when it is passed to the sort intrinsic by the program. The input file cannot be a file that is declared to be DIRECT.

If an input procedure is used as the input option, the procedure is called to furnish input records to the sort intrinsic. The input procedure must be a Boolean procedure, must not be declared EXTERNAL, and must have a one-dimensional array with a lower bound of zero as its only parameter. This procedure, on each call, either inserts the next record to be sorted into its array parameter or returns the value TRUE, which indicates the end of the input data. The input procedure must not contain any SORT or MERGE statement.

When TRUE is returned by the input procedure, the sort intrinsic does not use the contents of the array parameter and does not call the input procedure again.

The following is an example of an input procedure that can be used when sorting N elements of array Q:

BOOLEAN PROCEDURE INPROC(A);
ARRAY A[0];
   BEGIN
   N:= *-1;
   IF N GEQ 0 THEN
      A[0]:= Q[N]
   ELSE
      INPROC:= TRUE;
   END INPROC;
Note: The sort intrinsic maintains a logical record structure in memory. Be careful not to exceed the length of the record when manipulating records; data corruption might occur.