On Call Command

Purpose

Branch to one of several specified subroutines, depending on the value of an expression.

Syntax

On n Call proc0, proc1, …

n:iexp
proc0, proc1, …:name of a Procedure or Sub to jump to

Description

The value of n determines which subroutine is branched to in the procedure list. If the value of n is less than 1 or greater than the number of items in the list, then control drops to the statement following On Call.

Example

OpenW 1

Local a%, n%

n% = 3

On n% Call p1, p2, p3, p4, p5, p6

n% *= 2

On n% Call p1, p2, p3, p4, p5, p6

 

Procedure p1

Print "PROCEDURE P1"

Return

 

Procedure p2

Print "PROCEDURE P2"

Return

 

Procedure p3

Print "PROCEDURE P3"

Return

 

Procedure p4

Print "PROCEDURE P4"

Return

 

Procedure p5

Print "PROCEDURE P5"

Return

 

Procedure p6

Print "PROCEDURE P6"

Return

Remarks

Select Case provides a more structured and flexible way to perform multiple branching.

See Also

SelectCase, On GoTo, On GoSub

{Created by Sjouke Hamstra; Last updated: 20/10/2014 by James Gaite}