Jump to content
Daher

Repeat until given loops or time ?

Recommended Posts

Hi I want for example run a procedure around 60 times, or 60000 milliseconds if possible so I thought this would work:

 

begin

repeat

 

until 60; // loops

end;

 

or

 

begin

repeat

 

until 60000; //Ms

end;

 

How do I make it repeat as many times as I like it to do ?

Link to comment
Share on other sites

A simple timer using a while-loop.

var
 maxt: Integer;   

begin
 maxt := getSystemTime + 2000; //2000ms
 while(getSystemTime < maxt) do
 begin
   //Do something...
 end;
end.

 

Timer with repeat:

var
 maxt: Integer;   

begin
 maxt := getSystemTime + 2000; //2000 ms
 repeat
   //Do something...
 until (getSystemTime > maxt);
end.

 

-------------------

X iterations:

//Do X iterations
var
 maxI, I: Integer;   

begin
 maxI := 100; //iterations.

 for I:=0 to maxI do
 begin
   //Do something..
 end;
end.

Edited by slacky
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...