While Statement
Use the while
keyword to conditionally iterate a statement. The syntax of the while
statement is:
while expression do statement
statement
is executed repeatedly as long as expression
evaluates true. The test takes place before the statement
is executed. Thus, if expression
evaluates false on the first pass, the loop does not execute.
Here is an example of calculating scalar product of two vectors, using the while
statement:
s := 0; i := 0; while i < n do begin s := s + a[i] * b[i]; i := i + 1; end;
Probably the easiest way to create an endless loop is to use the statement:
while TRUE do ...;
Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
What do you think about this topic ? Send us feedback!