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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Try...catching errors in VFP7.0

Status
Not open for further replies.

DirkVFP

Programmer
Aug 25, 2005
57
NL
Hi all.

How do I do the following in VFP7.0?
Code:
nHandle = 0

TRY
   nHandle = FOPEN("foo.txt")
   < do some stuff >
CATCH
   MESSAGEBOX("IO error...")
FINALLY
   IF nHandle > 0 THEN 
      FCLOSE(nHandle)
   ENDIF
ENDTRY

Can't find these statements in VFP7.0. I know there's ON ERROR out there, but the above is the way I'm used to do error handling (doing Delphi and .NET).
 
Hi,

you have to use VFP9. TRY CATCH does not exist in VFP7.

EC
 

TRY/CATCH came in with VFP 8.

In earlier version, you do something like this:

Code:
lcOldErrorHandler = ON("ERROR")
ON ERROR llError = .T.
* do something dangerous
ON ERROR &lcOldErrorHandler
IF llError
  * an error occurred
ENDIF

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thanks Mike,

For now, this will do fine. Hope my boss will soon decide to spend some Euros on the newest version of VFP though ;-)

DirkVFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top