Rooster Posted August 22, 2014 Share Posted August 22, 2014 Hi all, How can I do the following and make ik work? begin While (condition) do begin if (condition) then begin command end; command command end; end. Because he perfectly checks for the while loop but it completely ignores the if... Any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
Neron Posted August 27, 2014 Share Posted August 27, 2014 (edited) IF statement is not a loop, will execute only once if true like: var i : integer; begin i := 1; while i < 5 do begin if i = 3 then begin writeln('middle loop! '); //other statements end; writeln(i); Inc(i); end; end. this example will write in debug: 1 2 middle loop! 3 4 Edited August 27, 2014 by Neron Quote Link to comment Share on other sites More sharing options...