A DO WHILE
loop will continue to loop unless the WHILE
-part is met. This makes it easy to run forever and eat up all time from one CPU core.
DO WHILE expression:
END.
expression is any combination of boolean logic, comparisons, variables, fields etc that evaluates to a true value.
/* This is a well defined DO WHILE loop that will run as long as i is lower than 10*/
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DO WHILE i < 10:
i = i + 1.
END.
DISPLAY i. // Will display 10
You can use any number of checks in the WHILE
-part:
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DO WHILE TODAY = DATE("2017-02-06") AND RANDOM(1,100) < 99:
i = i + 1.
END.
MESSAGE i "iterations done" VIEW-AS ALERT-BOX.
However, the compiler wont help you so check that the WHILE
-part eventually is met:
/* Oops. Didnt increase i. This will run forever... */
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DO WHILE i < 10:
i = 1.
END.