GoSub

Transfers control to another point in a WIL program and saves the location of the next statement.

Syntax:

GoSub label

Parameters:

(s) label user-defined identifier

 

GoSub label causes an unconditional transfer of control to the line in the program marked :label where the identifier is preceded by a colon (:). The location of the next statement after the GoSub statement is retained, and control may be transferred back to that statement with a Return statement.

Note: If you call GoSub from within a User Defined Function, the 'label' must be defined within the User Defined Function.

Labels for Goto and Gosub can be up to 249 characters.

Example:


a=1
b=2
c=3
x=21
GoSub Poly
Message("Polynomial evaluates to", y)
a=3
b=4
c=6
x=45
GoSub Poly
Message("Polynomial evaluates to", y)
Exit
; Polynomial Computation Subroutine here
:Poly
y = a*(x**2) + b*x + c
Return
See Also:

For, Goto, Return, Switch, Select, While, #Include