Writing subroutines
A subroutine is delimited like the POST actions.
Subroutines have a header and a trailer line:
\SUB <name>
...
... subroutine body
\END_SUB
You can add as many \SUB and \END_SUB sets as required. The following example illustrates a rules file organization:
\POST_START <name>
Actions
\POST_END <name>
%1U
CALL UNITS
%1R
CALL ROUTES
...
... Additional patterns and actions
...
\SUB UNITS
...
... Apartment processing patterns and actions
...
\END_SUB
\SUB ROUTES
...
... Route processing patterns and actions
...
\END_SUB
All subroutines are coded at the end of the file. The order of the subroutines themselves is unimportant. The subroutines contain the standard pattern action sets as found in the main rules.
Subroutines can be nested. That is, CALL actions are permitted within subroutines.
Control is returned back to the level from which a routine was called, either another subroutine or the main program, when the \END_SUB is reached or when a RETURN action is executed.