In your loop you'll have to check for and get any events on the event queue
in order to know that the button was pressed.  Since you didn't show the
code in your loop, I assume that you are not currently doing that.

Something like this:

while(loop)
{
        // do your stuff...

        if(EvtEventAvail())
        {       
                EventType       event;
                EvtGetEvent(&event, 0);
                // process event

                if(event == your button)
                        loop = false;
        }
}

Hope this helps,
Kevin

> -----Original Message-----
> From: Allen Yang [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 31, 1999 1:30 PM
> To: [EMAIL PROTECTED]
> Subject: How to stop infinite loop by push button or some other ways?
> 
> 
> Hi, 
> I have a question here. I built an application for 
> downloading data from
> another device. In the application, I created an infinite 
> loop for getting
> data all the time unless the user push "done" button in order 
> to terminate
> the loop and finish downloading. I did the following steps 
> for making "done"
> button work. However, when I tested it, it didn't do 
> anything. The infinite
> loop was still running.
> 
> I declare runLoop as varible to handle button.
> char      runLoop = 0;
> 
> In the form handler function,
> 
> static Boolean ldu_handler(EventPtr event) 
> {     // handles the events within the ldu form
>       FormPtr   form;
>       UInt       handled = 0;
>       UInt          index;
>       VoidHand      RecHandle;
>       Ptr           RecPointer;
>       
>       
>       form = FrmGetActiveForm();
> 
>       .............
>       //Here I ste up controlID for "done" button.    
>       case ctlSelectEvent:
>                       if (event->data.ctlEnter.controlID== 
> buttonID_ldu_done) 
>                       {       // if user pushes the done 
> button, return to
> main form
>                  runLoop = 0;
>                       FrmGotoForm(formID_main);
>                       handled = 1; 
>                       }
>                       break;
>       .............   
>       return handled;
> }
> 
> In the main function, I had the loop in the function
> 
> static void do_channel()
> {
>       
>       runLoop = 1;  //I set runLoop =1 so i can start 
> download date. if
> runLoop = 0, downloading shall stop.
> //Handle_Old_MF_Data();
> while (runLoop)
>  {    
>       ...............
> }
> 
> }
> 
> 
> Any advice will very appreciated.
> 
> Allen
> 

Reply via email to