Log in

View Full Version : How can I make a script repeat



KeepBotting
07-05-2012, 04:03 PM
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
07-05-2012, 04:05 PM
Try using the For.. To.. Do Loop

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

Caotom
07-05-2012, 04:07 PM
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
07-05-2012, 04:07 PM
Or alternatively:
var I: Integer;

I := 0;

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

KeepBotting
07-05-2012, 04:07 PM
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?


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
07-05-2012, 04:23 PM
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
07-05-2012, 04:25 PM
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