WHILE CYCLE

Back to:
index

This cycle reiterates its contents while the condition in the head of the cycle is TRUE. When the result of condition analysis becomes FALSE, cycle ends.

The condition is placed between WHILE and DO reserved words. Condition analysis compiling is described on special page. You may also want to see the description of some assign operator details.

Examples and operator structure

"E97" code examples

Intel code examples


Examples and operator structure

Typical examples of WHILE cycle, available in "COMPAS" are the following:

  • WHILE s[i] <> ' ' DO i := i + 1;
  • WHILE a < 10 DO BEGIN s := s + a; a := a + 1 END;
  • WHILE b DO BEGIN w := w-1; b := w=0 END;

Possible structures of this operator can be written the following way:

WHILE {condition} DO {operator} ;

WHILE {BOOLEAN variable} DO {operator} ;

Note, that instead of {operator} several operators, confined between reserved words BEGIN and END - so called compound statement - can be used.

If we compare the short variant of IF (left) with WHILE operator (right), we should see, that they look very similar:
short IF scheme WHILE scheme
The only difference is jump to the beginning of the cycle in the second case. So it's no wonder, that the realization of these structures are similar enough too.



Back to:
index top E97 Intel