Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shutdown and EXE
Message
From
01/05/2009 15:48:19
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
01/05/2009 14:45:59
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
01397454
Message ID:
01397519
Views:
36
>>The simple way could be to add to your main program
>>
>>on error do ErrorHandler with error(), message() etc. and then have this routine to exit gracefully.
>
>I have a try/catch that assembles an error message and returns it to the webpage when the routine has an error. But what about an infinate loop? In this case there isn't technically an error that would trigger the error handler. The program just goes off and never comes back. So I think I need a timer somehow. But how to add it to the custom class of the EXE and would it even work if the function was stuck in a loop?

Depends on where the loop is. If you're having a do-while loop or some other VFP loop, then just put a counter in the loop, so have a do while nCounter < 20000 or some other number which wouldn't come up in real life, but would eventually come to that if the loop is infinite. Of course, increase the counter on each pass.

Another way is to limit the time. Save the current seconds() value plus some predetermined allowed runtime - maybe a minute or two - and once each loop (or each ten passes - your thumb's rule) check whether current value of seconds() is above that.

Either way, you have a criterion on when to bail out, raise an error and let your error handler do the rest. You can have a custom

error "loop took too long, just gave up"

or whatever would not annoy your users too much.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform