SRL Archive - OSR Help

Return to while do after action


klinnks

2013-01-21 15:43:45

This might be a noob question but I want to do all three actions only one time each and in order BUT return to the while(condition) between every action,

How?

Example

while (condition) do
Action(1); //Do this once and go back to top, then go straight to action 2
Action(2);
Action(3);


NKN

2013-01-21 22:17:50


while(i<=3) do
begin;
i := i + 1;
action(i);
end;

Wardancer

2013-01-21 22:59:00

Why not a "for i = 1 to 3 do"? It seems much more intuitive to me for the task you have in mind. That being said, every loops could be used to do the same task.


i := 1; //Didn't want to copy NKN's way of doing it, haha
repeat
action(i);
Inc(i);
until i = 3;