WHILE
Repeatedly execute a statement
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
WHILE condition [DO] statement
Arguments
condition
A conditional expression that is evaluated before each repetition of the specified statement.
statement
A single or compound statement to be executed repeatedly.
Discussion
The WHILE statement executes a statement repeatedly as long as a specified condition is true. Statement is executed while condition is true. When the condition becomes false, control transfers to the logical statement after the WHILE.
Statement can be on the next logical line from WHILE condition. If DO is present, it must be on the same logical line as WHILE.
Statement is not executed if condition is false at the initial iteration. |
Examples
The following example performs password validation.
.define TTCHN ,1 record password ,a5 proc open(TTCHN, o, "tt:") xcall flags(50000, 1) ;Turn off input echo while (password .ne. "DEMO ") do begin display(TTCHN, "Enter password: ") reads(TTCHN, password, exit) if (password .ne. "DEMO") begin writes(TTCHN, "Invalid password") sleep 1 end end display(TTCHN, $scr_clr(screen), "XYZ Payroll System") xcall process ;Start the package exit, stop end