SRL Archive - Help

How can I make a script repeat


KeepBotting

2012-07-05 12:03:57

A set amount of times?

Say, something like

repeat
{ stuff }
until(3) //the until would make it try 3 times to do stuff

Any way?

Based Lord

2012-07-05 12:05:44

Try using the For.. To.. Do Loop

For i:=0 to 3 Do
Begin
Stuff;
MoreStuff;
End;

Caotom

2012-07-05 12:07:19

A basic way of doing this would be having an integer that simple increases every time:

I := 0;
repeat
Stuff;
I := I + 1
until(I >= 3)

~Caotom

Frement

2012-07-05 12:07:36

Or alternatively:
var I: Integer;

I := 0;

repeat
//MyStuff;
Inc(I);
until(I >= 3);

KeepBotting

2012-07-05 12:07:57

From: Based Lord
Try using the For.. To.. Do Loop

For i:=0 to 3 Do
Begin
Stuff;
MoreStuff;
End;
And using that, I do not need an until, it only matters where I place the For.. To.. Do loop, correct?

From: Frement
Or alternatively:
var I: Integer;

I := 0;

repeat
//MyStuff;
Inc(I);
until(I >= 3);
That's a little more understandable to me. I'll try both ways. Thanks guys!

Wreck

2012-07-05 12:23:43

Another loop you can use is While … Do for example:

var i: Integer;

i := 0

While (i < 5) Do
begin
DoStuff;
IncEx(i, 1);
writeln(IntToStr(i));
end;

KeepBotting

2012-07-05 12:25:58

From: Wreck
Another loop you can use is While … Do for example:

var i: Integer;

i := 0

While (i < 5) Do
begin
DoStuff;
IncEx(i, 1);
writeln(IntToStr(i));
end;
Wow, now I really hadn't thought of that. How ingenious! :P