5.4.2.16 On…GoSub Statement

 on-gosub-statement = "On" expression "GoSub" statement-label-list 

Static Semantics.

§ A procedure MUST contain exactly one <statement-label-definition> for each <statement-label> in a <statement-label-list>.

Runtime Semantics.

§ Let n be the value of the evaluation of <expression> after having been Let-coerced to the declared type Integer.

§ If n is zero, or greater than the number of <statement-label> defined in <statement-label-list>, then execution of the <on-gosub-statement> immediately completes.

§ If n is negative or greater than 255, an error occurs (number 5, "Invalid procedure call or argument").

§ Execution branches to the <statement-label-definition> for the n’th <statement-label> defined in <statement-label-list>.

§ If the n’th <statement-label> defined in <statement-label-list> is the same as the <end-label> of lexically enclosing procedure declaration execution of the current <procedure-body> immediately completes as if statement execution had reached the end of the <procedure-body> element’s contained <statement-block>.