Kevin:
Thank you for your help with my problem.  I made some changes, and tried to
get out the loop by pushing "done" button. However, I got some strange
errors. Would you mind give me some advice for this.
while (runLoop)
{
..............
if (EvtEventAvail())
{
      EventType event;
      EvtGetEvent(&event, 0);

      if (event->eType == ctlSelectEvent)
      {
       if (event->data.ctlEnter.controlID == buttonID_ldu_done)
          runLoop = 0;        
        } 
}
FrmGotoForm(formID_main); // loop done; goto main form
}       
I got five different kinds of errors. 
First one, In if (event->eType == ctlSelectEvent) statement, Error is
pointer/array required. I basically use the same statement (in ldu_handler
function). I don't understand why it is wrong here? Another one is in if
(event->data.ctlEnter.controlID == buttonID_ldu_done) statement, Error is
';' expected. I don't know why I need put ';' after if statement. Third one
is in runLoop = 0 statement, error is that not an lvalue. What is lvalue?
Why I need lvalue here for runLoop? Fourth one is in
FrmGotoForm(formID_main)statement, error is that declaration syntax error. I
also used the same statement as before. Why compiler gave me error here?
The last one is for "}", declaration syntax error.

Thank you for your time and help.

Allen   
-----Original Message-----
From: Kevin O'Keefe [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 31, 1999 5:01 PM
To: '[EMAIL PROTECTED]'
Subject: RE: How to stop infinite loop by push button or some other
ways?


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