Switch File List

An integer index is associated with each file designator in the switch file list. The indexes are 0, 1, 2, and so on through N–1, where N is the number of file designators in the list. These indexes are obtained by counting the file designators in order of their appearance in the list. A file designator in the list can be referenced by subscripting the switch file identifier with a subscript whose value is equal to the index of the file designator.

If a subscript to a switch file identifier yields a value outside the range of the switch file list (that is, less than 0 or greater than N–1), a fault occurs at run time.

Any subscripts in the switch file list are evaluated at the time of the SWITCH FILE declaration.

A switch file can reference itself in the switch file list, in which case a stack overflow might occur when the program is executed. For example, assume a switch file is declared as the following:

SWITCH FILE SF := F1, F2, SF[N]

If N equals 2, the subscripted switch file identifier SF[N] references itself indefinitely.

The switch file list of a switch file that is not designated as DIRECT can contain only file designators that are not DIRECT, and the switch file list of a switch file that is designated DIRECT can contain only file designators that are DIRECT.