The answer is, there are two ways.

1) code your long-running process as a function that performs one step per
call, and then returns. Recode your main event loop such that it returns
nillEvents when there are no events (i.e., pass a timeout value other than
forever in the GetNextEvent() call) and then call your work function every
time there is a nil event sent to your handler. This approach requires a lot
of statics and/or globals to maintain the current state of the work
function.

2) code your long-running process as is, but include a call to
GetNextEvent() with a timeout of 0 within the loop. If you get a non-nil
event that is a pendown, and the pendown is within the "Stop" button bounds,
then stop.

John Schettino
Palm OS Programming For Dummies: http://schettino.tripod.com


-----Original Message-----
From: Jason Simpkins [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 05, 2000 9:37 AM
To: Palm Developer Forum
Subject: Intercepting Form Buttons From within an EventHandler


Hello All,

I need to be able to break out of a loop that startes from within an
EventHandle function but have been unsuccessful in figureing this out.  Here
is the pseudo code;

case MainFormButton :   while( not end if database  and  NotRecord we seek){

                                                 getNextRecord(database);

                                                 if( Record is correct
one ){

                                                            EndRecordSearch
= True;

                                                }

                                                if
 MainFormCancelSearchButtonPressed == True){

                                                            EndRecordSearch
= True;
                                                            UserCancel =
True;

                                               }

                                        } /* end while loop */



The crux here is how do you intercept an Event when you are already inside
of an Event Handler?


Thanks,

Jason


-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to