SRL Archive - OSR Help

if... then loop back?


Sin

2012-01-25 19:27:02

Is there anyway to -


procedure sfhsdibsi
begin

if someshit happens then
begin
dealwiththat
loopbacktobeginning of procedure
end;

end;
Help plox :)

weequ

2012-01-25 19:29:33


procedure sfhsdibsi
begin
while someshit happens do
begin
dealwiththat
end;

end;
Like that?

Kasi

2012-01-25 19:29:46

Label's, i think
why not just stick the whole thing in a repeat?

Inception

2012-01-25 19:31:42

Try something like this:


procedure Recursion;
begin
if test then
begin
//stuff....
Recursion;
end;
end;

Narcle

2012-01-25 19:33:38

This is why I use .Loc system.

Kasi

2012-01-25 19:34:03

that thread has a good example for label's they dont get used often
http://villavu.com/forum/showthread.php?t=35035

just saying :)

WT-Fakawi

2012-01-25 19:38:43

From: S1N
Is there anyway to -


procedure sfhsdibsi
begin

repeat
moreshitbackatbeginning;
repeat
lostofunneccesaryshit;
if someshit happens then
begin
dealwiththat
break; // loopbacktobeginning of procedure
end;
until noshit
until whateverstop
end;
Help plox :)


I think I'd do it that way :smile:

weequ

2012-01-25 19:45:16

From: Inception
Try something like this:


procedure Recursion;
begin
if test then
begin
//stuff....
Recursion;
end;
end;
I don't recommend doing this. With recursion it would use more memory and it will finish the procedure after the recursion is done. As far as I know you should only use recursion when you have to program a varying amount of loops inside loops.

like..

for
for
for
for
...

Inception

2012-01-25 19:50:45

From: weequ
I don't recommend doing this. With recursion it would use more memory and it will finish the procedure after the recursion is done. As far as I know you should only use recursion when you have to program a varying amount of loops inside loops.


You could just add an Exit after the recursion call, right?


procedure Recursion;
begin
if test then
begin
//stuff....
Recursion;
Exit;
end;
end;

weequ

2012-01-25 19:59:47

From: Inception
You could just add an Exit after the recursion call, right?


procedure Recursion;
begin
if test then
begin
//stuff....
Recursion;
Exit;
end;
end;
Yup you could do that but I think there are better alternatives since the recursion has to keep the old function 'loaded' and will use more memory. (It performs the Recursion call before the exit)