Routines

A ROUTINE is a set of sort commands which are physically placed after the main command section and accessed by a CALL command within the main section. The last command in a ROUTINE should be END or ENDEVENT. END returns event processing to the command following the CALL command. when the routine has been executed whereas ENDEVENT terminates processing of the current event at that point in the sortfile.

A routine must be called at least once before it is defined in the sortfile so that the argument types can be determined, i.e. word, long or float, before the routine is specified. The current maximum number of arguments that may be passed to a routine may be found in Appendix A. If a sortword argument is specified any operation performed on that parameter within the routine will result in a corresponding change in value of the sortword upon returning from the routine,

Example

IF GELI3 GATEDBY GLIST2 {
    SELECT(GATE) {
        (1) CALL ABC(SUMEN,INDEX)
        (2) CALL XXXXYYYY
            ...
    }
}
END
ROUTINE ABC(ENERGY,OFFSET)
    ...
CALL XXXXYYYY
    ...
END
ROUTINE XXXXYYYY
    ...
END

where SUMEN and INDEX are sortwords, ENERGY and OFFSET are dummy sortword arguments local to the routine ABC.


Calls may be nested up to a maximum level of 8, but routines must not be called recursively, i.e. a routine may not call itself or one that directly or indirectly calls it. A routine must be called at least once before it is specified, i.e. at least one CALL statement for a given routine must occur before the ROUTINE statement in the sortfile.