Menu

More on while .. do

'while .. do' loops have been added to the GibPascal 1.3 release.

Usage format is as following:

[while [variable]|[count]|[<|>] [value] do begin ... end]

Here is an example of the 'while .. do' using a variable:

loop1 := 5;
while loop1 < 10 do
begin
loop1 := loop1 + 1;
loop2 := loop2 + 2;
writeln('loop1 = ',loop1,' loop2 = ',loop2);
end;

This example would run the three internal loop statements 5 times.

Here is an example of the 'while .. do' with the 'count' reserved word:

while count 12 do
begin
loop1 := loop1 + 1;
loop2 := loop2 + 2;
writeln('loop1 = ',loop1,' loop2 = ',loop2);
end;

This would run the three internal loop statements 12 times.

Posted by Michael Ralph Gibson 2021-11-17

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.