── SUBROUTINE ──<subroutine identifier>─┬─────────────────────────┬────► └─<subroutine parameters>─┘ ►─ ; ─┬─<statement>────────┬───────────────────────────────────────────┤ └─<subroutine block>─┘
┌◄────────────────────── , ─────────────────────┐ ── ( ─┴─┬─ BOOLEAN ──<Boolean identifier>─┬─────────┬─┴─ ) ────────────┤ │ └─ VALUE ─┤ ├─ INTEGER ──<integer identifier>─┬─────────┤ │ └─ VALUE ─┤ ├─ REAL ──<real identifier>─┬───────────────┤ │ └─ VALUE ───────┤ ├─ STRING ──<string identifier>─┬───────────┤ │ └─ VALUE ───┤ ├─ FILE ──<file identifier>─────────────────┤ └─ TASK ──<task identifier>─────────────────┘
── BEGIN ─┬────────────────────┬─┬──────────────────┬─ END ────────────► └─<declaration list>─┘ └─<statement list>─┘ ──┬─────────────────────────┬──────────────────────────────────────────┤ └─<subroutine identifier>─┘
Explanation
A subroutine declaration identifies a series of statements that are executed when the subroutine is invoked by a subroutine invocation statement. The subroutine invocation statement is described in Statements.
The simplest form of a subroutine consists of the subroutine heading, followed by a single statement. Declarations and multiple statements can be included in the subroutine, but they must be bracketed by the words BEGIN and END.
Any kind of WFL declaration can be included in a subroutine except for file declarations and global data specifications. However, subroutines can include local data specifications, and references to global data specifications and files that are declared globally. Variables declared in a subroutine are local to that subroutine (refer to Scope of Declarations).
The WFL statements are described in Statements.
WFL enables a subroutine identifier to be repeated after the end of the subroutine. This feature helps create WFL jobs that are easier to read, especially in cases where nested subroutines occur. If a subroutine identifier is specified after END, it must be the same subroutine identifier specified at the start of the declaration.
A subroutine declaration can include another subroutine declaration within itself. This is referred to as nesting. Subroutines can be nested to a maximum of 10 levels.
-
WFL jobs that have nested subroutines can result in larger code files due to the new Long Name Call/LNMC, Long Value Call/LVLC code, which replaces Name Call/NAMC, Value Call/VALC and uses more bytes.
-
If the WFL compiler issues a warning message that a code segment exceeds its capacity, then you must split the statements in that subroutine into multiple subroutines. Ignoring the warning message can result in the initiation or compilation of a WFL job being aborted.
-
If the WFL compiler issues a warning that a code segment exceeds its capacity and that code segment is the outer block of the WFL job, then you must move code from the outer block into multiple subroutines. Ignoring the warning message can result in the initiation or compilation of a WFL job being aborted.