OSVS 

The ON Statement

The ON statement allows selective execution of procedural statements on a periodic basis.

General Format


ON Statement

Syntax Rules

  1. Identifier-1, identifier-2 and identifier-3 must describe unsigned integer numeric elementary items.
  2. Literal-1, literal-2 and literal-3 must be unsigned numeric literals.
  3. The ON statement is not supported in class programs when compiling to managed code.

General Rules

  1. Prior to the first execution of each ON statement , a counter, implicitly defined for that ON statement (the implicit-ON-counter), is initialized to be zero.
  2. Identifier-1, identifier-2 and identifier-3 should, if specified, contain positive integer values at the time of execution of the ON statement. Varying these values between executions of the ON statement will affect subsequent executions of the ON statements.
  3. The implicit ON counter cannot be affected in any way other than by transfer of execution flow to that ON statement. (The ON counter of a called program can only be reset by the canceling of that program; execution of the EXIT PROGRAM statement and subsequent CALL of the program without intervening CANCEL has no effect upon the implicit ON counter value.)
  4. The following value-list is then evaluated:
    1. The current value of identifier-1 or literal-1,
    2. A sequence of values being the results of repeatedly adding the current value of identifier-2 or literal-2 to the current value of identifier-1 or literal-1 until the value of identifier-3 or literal-3 is reached.

    The implicit-ON-counter is then compared with each of this list of values. If an equality is found, then imperative-statement-1 is executed. If no equality is found, then imperative-statement-2, if specified, is executed.