Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Try/Catch
Message
From
20/06/2003 16:32:12
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00802432
Message ID:
00802434
Views:
18
Markus has an article at http://www.code-magazine.com/focus/Article.aspx?quickid=0301072


>I am trying to use the new try/catch error handling in a very simple backup application that I am writing. The program is very simple and has no other error handling at this time. What I would like to do is try to open a file exclusive. If the file opens exclusively, perform the backups. Otherwise generate a message and kick the user out of the method. Here is the code I am working with:
>
try
>    use customer excl
>catch when .t.
>    messagebox('Unable to Open Files Exclusive')
>endtry
>close all
>do backups
>
>
>I could easily accomplish what I want by setting a flag in the catch statement and testing the flag after the endtry. However, I am trying to learn the 'correct' way to use the try/catch statements instead of doing what comes naturally to me. Reading through the help files it would appear that the typical thing is to throw an error and have it caught by a higher level catch statement. That seems like a bit of a drastic idea in this case but maybe its the way things are suppose to be done.
>Can anyone give me some advice please?
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform