|
| Re: PLEASE HELP - loop exit problem |
 |
Sat, 14 Jul 2007 15:04:05 -050 |
Marko,
I believe you need to place Application->ProcessMessages(); at the top of
your for loop so the application will process any button clicks at the
beginning of each loop. Then your if statement in the for loop will see the
change to "continue"
Larry J.
"Marko" <marko@marko.webserwer.pl> wrote in message
news:46991470@newsgroups.borland.com...
> hello
>
|
| Post Reply
|
| Re: PLEASE HELP - loop exit problem |
 |
Sat, 14 Jul 2007 16:47:42 -070 |
"Marko" <marko@marko.webserwer.pl> wrote in message
news:46991470@newsgroups.borland.com...
> there is a for loop in my software i need to terminate by SpeedButton
Your loop needs to call Application->ProcessMessages() periodically in order
for the OnClick event to function while the loop is running.
> while a loop is running i can't change the "continue" variable.
That is because you are not letting new messages be pumped from the message
queue.
Gambit
|
| Post Reply
|
| Re: PLEASE HELP - loop exit problem |
 |
Sat, 14 Jul 2007 16:49:04 -070 |
"LarryJ" <LarryJ33@austin.rr.com> wrote in message
news:46992c32$1@newsgroups.borland.com...
> I believe you need to place Application->ProcessMessages();
> at the top of your for loop so the application will process any
> button clicks at the beginning of each loop.
Do not call it on each loop iteration. ProcessMessage() is an expensive
call to make. It will seriously degrade overall performance of the
application if you call it that often. Call it every 10th or 100th
iteration, for instance.
Gambit
|
| Post Reply
|
| PLEASE HELP - loop exit problem |
 |
Sat, 14 Jul 2007 20:22:28 +020 |
hello
i have a problem with loop exit operation
there is a for loop in my software i need to terminate by SpeedButton
my loop looks like this (for example)
for(int i=0; i<2500; i++)
{
if(continue==false) break; //exit from the loop on request
//other RS232 operations
}
im seting the "continue" variable to false state by clicking a
SpeedButton
void __fastcall TForm1::SpeedButtonSTOPClick(TObject *Sender)
{
continue=false; //continue is a global variable
}
but.... while a loop is running i can't change the "continue"
variable.
my software is busy ... the SpeedButtonSTOPClick function is called just
after that (but it's too late)
|
| Post Reply
|
|
|
|
|
|
|
|
|
|