Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error handler (specifically feature not available #1001)

Status
Not open for further replies.

kenndot

Programmer
Joined
May 15, 2001
Messages
316
Location
US
I'm trying to build a generic error handler. One of the errors I am trying to catch and take care of is 1001, where in case a suspend or set step on is left in the code, the error handler would handle this error by simply returning the focus back to the program at the following line of code (after the set step or suspend)

Couple of problems..

1. I am getting a completely different error than 1001 - I continue to get "Invalid file or path name" and it's the suspend or set step on that generates it, too. Anyone know why you would get that from a suspend or set step?

2. The errors that do get caught I simply send the user a message telling them that something went wrong and to call the helpdesk - but before sending the focus to the error handler, the regular foxpro error message is still coming up and when you cancel out of that THEN you get the error handler message that I created. Why would this happen?

My main focus right now is getting error 1001 handled to simply ignore the suspend or set step on commands.

I know I can do a much better job of this in version 8 but my company isn't planning to go to that for a while, so I need to stick with what is available in version 6, thanks.

Thank you all
 
You may want to read Doug Hennig's whitepaper on VFP error handling - it's a classic. Go to - "Error Handling in Visual FoxPro (370K)".

While this doesn't cover the new VFP 8.0 TRY...CATCH...FINALLY feature, most of us are still learning about it anyway.

Rick
 
Kenndot,

While I agree with Rick's advice about reading Doug Hennig's paper, I don't this will answer your specific question.

I think your problem is that the SUSPEND command is looking for the source code, and as this is not available, you are getting the invalid file message. (I believe this behaviour was changed in VFP 8.0, which just ignores the command.)

An alternative would be to put this line:
#DEFINE SUSPEND NOTE
at the top of your program. This will in effect comment-out all the SUSPEND's.

Mike


Mike Lewis
Edinburgh, Scotland
 
Hi Mike,

Thanks for the idea. I tried it and am still running into the same problem, though. In the MSDN, I read the following - Do not use Visual FoxPro keywords for constant names. I assumed this meant SUSPEND?

Have you successfully used this in your code? I put it in the MAIN.prg of the program because I wanted it to be global. I tried using '*' as well. I don't know what else to try, any ideas what I am doing wrong?
 
Kendot,

I should have explained that, to make the #DEFINE available, you would have to insert it in every PRG or method that uses it. Or, put it in a header file, which you reference from _INCLUDE.

In the MSDN, I read the following - Do not use Visual FoxPro keywords for constant names. I assumed this meant SUSPEND?

Yes, that would include SUSPEND. But I was not suggesting that you use it as a constant name. #DEFINE isn't just used for creating constants. You can use it to modify the action of your code, which is what I was suggesting here. There is certainly no syntactically reason for not using SUSPEND in this context.

However, none of this is really necessary. I still think the best solution would be to not leave the SUSPENDs in your code in the first place. SUSPEND is a programmer's aid. It has no place in finished code. If you do leave it in accidentally, it is right that your error handler reports its an error.

Mike


Mike Lewis
Edinburgh, Scotland
 
The idea was to write the error to a file, but not show the actual message to the user to just resume program without error, but you have a very good point. Unfortunately it's my boss who is asking for this... maybe I can persuade him otherwise.

 
Kendot,

. Unfortunately it's my boss who is asking for this... maybe I can persuade him otherwise.

Well, just tell him that some 'expert' you met at Tek-Tips said so <g>.

Mike



Mike Lewis
Edinburgh, Scotland
 
that should work! HA HA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top