重复

REPEAT 将永远重复,除非你明确退出循环:

//Runs forever
REPEAT:
    // Do stuff
END.

要退出循环,你可以使用 LEAVE 关键字。有无标签。如果没有标签,LEAVE 将始终影响当前循环。使用名称,你可以指定 LEAVE 的循环。

/* Without a label */
REPEAT:
  //Do stuff
  IF TRUE THEN LEAVE.
END.

/* With a label */
loopLabel:
REPEAT:
  //Do stuff
  IF <somecondition> THEN LEAVE loopLabel.
END.

/* Two nested REPEATS */
DEFINE VARIABLE i AS INTEGER     NO-UNDO.
loopLabelOne:
REPEAT:
    loopLabelTwo:
    REPEAT:
        i = i + 1.
        IF RANDOM(1,100) = 1  THEN LEAVE loopLabelTwo.
        IF RANDOM(1,100) = 1  THEN LEAVE loopLabelOne.
    END.
    IF RANDOM(1,100) = 1  THEN LEAVE loopLabelOne.
END.
DISPLAY i.