| View previous topic :: View next topic |
| Author |
Message |
DevilGilad Grandmaster Cheater
Reputation: 0
Joined: 10 May 2007 Posts: 624 Location: Delete C:\WINDOWS folder and you'll be able to see me.
|
Posted: Wed Jul 04, 2007 2:20 am Post subject: [Help] Making a loop\repeat on Delphi |
|
|
How can I make a loop\repeat on Delphi?
Thx.
_________________
|
|
| Back to top |
|
 |
Simsgy Grandmaster Cheater
Reputation: 0
Joined: 07 May 2007 Posts: 581 Location: My new avatar <3
|
Posted: Wed Jul 04, 2007 4:18 am Post subject: |
|
|
Use a Timer.
Make it usualy enabled := false, but when you want to active the loop, do Timer.Enabled := True.
Double click on the timer, and enter what ever you want it to do, and in the timer interval, enter the milliseconds between his loops.
_________________
|
|
| Back to top |
|
 |
Uzeil Moderator
Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Wed Jul 04, 2007 5:56 am Post subject: |
|
|
| Code: | var i: dword;
begin
for i:=0 to 10 do
showmessage('For Loop: Currently on number '+IntToStr(i));
while i>0 do
begin
dec(i);
showmessage('While Loop: Currently on number '+IntToStr(i));
end;
Repeat
inc(i);
showmessage('Repear Loop: Currently on number '+IntToStr(i));
Until
i=10;
end; |
Should all work. I may be wrong on the Until keyword, but I'm relatively certain.
_________________
|
|
| Back to top |
|
 |
Simsgy Grandmaster Cheater
Reputation: 0
Joined: 07 May 2007 Posts: 581 Location: My new avatar <3
|
Posted: Wed Jul 04, 2007 8:18 am Post subject: |
|
|
| Uzeil wrote: | | Code: | var i: dword;
begin
for i:=0 to 10 do
showmessage('For Loop: Currently on number '+IntToStr(i));
while i>0 do
begin
dec(i);
showmessage('While Loop: Currently on number '+IntToStr(i));
end;
Repeat
inc(i);
showmessage('Repear Loop: Currently on number '+IntToStr(i));
Until
i=10;
end; |
Should all work. I may be wrong on the Until keyword, but I'm relatively certain. |
Why messing up?
Using a timer is much more easy.
_________________
|
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Wed Jul 04, 2007 8:26 am Post subject: |
|
|
Because he asked for a loop and its better to use for,while then using a timer.
_________________
|
|
| Back to top |
|
 |
Simsgy Grandmaster Cheater
Reputation: 0
Joined: 07 May 2007 Posts: 581 Location: My new avatar <3
|
Posted: Wed Jul 04, 2007 8:30 am Post subject: |
|
|
Isn't it the same (I'm not saying I didn't use for in my SimsAC)?
_________________
|
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Wed Jul 04, 2007 8:44 am Post subject: |
|
|
I have never seen a timer being used as a loop in any example, source code, documentation. (As long as I remember)
And using for loop is easy and it works great, | Code: | int i;
for(i=0;i<5;i++)
{
// loop body here....
} |
Loops five times, how would you do that with a timer? Even if it's possible, it's not the best thing to do.
_________________
|
|
| Back to top |
|
 |
Simsgy Grandmaster Cheater
Reputation: 0
Joined: 07 May 2007 Posts: 581 Location: My new avatar <3
|
Posted: Wed Jul 04, 2007 9:15 am Post subject: |
|
|
Oh!
You was talking on an timer with an end.
I was talking on an endless timer.
_________________
|
|
| Back to top |
|
 |
UnLmtD Grandmaster Cheater
Reputation: 0
Joined: 13 Mar 2007 Posts: 894 Location: Canada
|
Posted: Wed Jul 04, 2007 9:26 am Post subject: |
|
|
for (;
{
}
Endless loop.
_________________
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Wed Jul 04, 2007 9:52 am Post subject: |
|
|
| zomgiownyou wrote: | for (;;)
{
}
Endless loop. |
you can't do that with delphi (unless you use GOTO, which might confuse people), always has to be some kind of logical statement :(
|
|
| Back to top |
|
 |
|