|
|
Topic complex |
Language elements |
Function |
WHILE |
Short |
Rejecting program loop |
Syntax |
WHILE boolexp DO Anweisungen END |
Parameter |
boolexp: logical expression, selection |
Return |
|
See also: |
|
Description |
WHILE leads to a so called rejecting loop. The logical expression is tested. If the test returns TRUE, all the orders between DO and the corresponding END are executed. After that the whole games starts again, as long as the expression returns TRUE.
If the very first test of the expression returns FALSE, the loop won't be processed even once.
Example:
VAR i : INTEGER
WHILE i++<=10 DO
cgiwriteln(str(i))
END
|
Example 1:
Give out a complete textfile line by line
VAR t : INTEGER
IF t:=reset('mytext.txt') THEN
WHILE NOT EOT(t) DO
cgiwriteln(readln(t))
END
close(t)
END
|
Write a comment:
|
|
|