LOTUSSCRIPT LANGUAGE


On...GoSub statement
Example

Transfers control to one of a list of labels, processes statements until a Return statement is reached, and returns control to the statement immediately following the On...GoSub statement.

Syntax

On numExpr GoSub label [ , label, ... ]

Elements

numExpr


label
Usage

The On...GoSub statement, its labels, and the Return statement must all reside in the same procedure.

LotusScript transfers control to the first label if numExpr is 1, to the second label if numExpr is 2, and so on. Execution continues from the appropriate label until a Return statement executes. Then control returns to the statement immediately following the On...GoSub statement. If LotusScript encounters a statement (such as Exit or GoTo) that forces an early exit from the procedure before reaching a Return statement, the Return statement is not executed.

LotusScript rounds numExpr to the nearest integer before using it to determine the target label. If numExpr is 0, or is larger than the number of labels in the list, the On...GoSub statement is ignored and execution continues at the statement that immediately follows it.

LotusScript generates an error if numExpr evaluates to a number less than 0 or greater than 255.

Example
See Also