Directives
WHILE ..WEND Repeat Statements
   
Format WHILE expression
...

WEND
   
  Where:
expression An expression whose value determines if the condition is True or False.
In numeric expressions a zero value will indicate FALSE, otherwise any non-zero value will indicate TRUE.
In string expressions a null (empty or blank) value will indicate FALSE, otherwise any non-null value will indicate TRUE.

Use of a string expression is a +PxPlus Exclusive (Version 10)

   
Description Use the WHILE directive for conditional looping in a program. ProvideX executes all directives between a WHILE directive and the next WEND directive repeatedly until the value of the numeric expression is 0 (zero).

When ProvideX encounters a WHILE directive, it evaluates the numeric expression. If the expression returns a TRUE value (non-zero for numeric, non-null for string), ProvideX/PxPlus continues execution until a corresponding WEND directive is encountered, at which point the numeric expression is re-evaluated. ProvideX/PxPlus continues to loop back to the directive following the WHILE directive until the expression yields a FALSE value. At this point, ProvideX advances to the next WEND directive, where it terminates the loop. Then control transfers to the statement following the WEND.

If ProvideX/PxPlus encounters a WEND directive but is not currently processing a WHILE / WEND loop, it returns an Error #27: Unexpected or incorrect WEND, RETURN, or NEXT. All FOR/NEXT, GOSUB/RETURN, and WHILE/WEND sequences executed within the WHILE/WEND loop must be completed.

Use a conditional EXITTO or BREAK to exit a WHILE/WEND loop early.

   
See Also BREAK Immediate Exit of Loop,
CONTINUE Initiates Next Iteration of Loop
EXITTO End Loop, Transfer Control.
Structured Error handling using ON ERR - an +PxPlus Exclusive
   
Example 0100 WHILE A$<>"E"
0110 LET K$=KEY(1,END=1000)
0120 READ (1)N$
0130 PRINT "Key: ",K$," Name: ",N$
0140 INPUT "Delete (Y/N):",A$
0150 IF A$="Y" THEN REMOVE (1,KEY=K$)
0160 WEND
0170 STOP
1000 PRINT "End-of-file..."
1010 EXITTO 0170