Previous Topic: IFNext Topic: WHILE


NEXT

Purpose

Exits IF and ON command processing.

Syntax

►►─── NEXT command ─── . ─────────────────────────────────────────────────────►◄

Usage

Definition

The NEXT command is used to exit IF and ON command processing. When a NEXT command is used, control passes to the command following the IF or ON statement.

Considerations

Example

The statements below illustrate the use of the NEXT command to match the second ELSE clause with the second IF command:

IF A = B
THEN
  DO.
    IF X = Y
    THEN
        IF Y = Z
        THEN
            MOVE A TO B.
        ELSE
            NEXT.
    ELSE MOVE B TO A.
    SNAP ALL.
    DISPLAY.
  END.

If A equals B and X equals Y, but Y does not equal Z, control exits from the innermost IF command and passes to the SNAP ALL command. If the ELSE NEXT statement is not included, the ELSE MOVE B TO A statement is matched incorrectly with the third rather than with the second IF.

More information:

Database Access Commands

IF