Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error Trapping
Message
From
14/04/2004 02:15:45
 
 
To
14/04/2004 00:53:44
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00894669
Message ID:
00894686
Views:
14
>Hi All,
>
>Is there a way to trap error when using the CreateObject or NewObject function?
>
>loFDF = CREATEOBJECT("fdfApp.FdfApp")
>
>fdfApp.FdfApp is class from adobe Acrobat's FDF for populating the VFP data onto .PDF form. If a user did not registered the dlls, this line gave me an error indicating there is no such class.
>
>I want to display a message telling the user that they need to register the .dlls before continue. Any Ideas to solve this problem?
>
>Thanks


Mathew. There are two options. TRY...CATCH...FINALLY or an ON ERROR.
TRY 
  oTest = CREATEOBJECT( "fdfApp.FdfApp" )
  * do something with your object
CATCH
  =MESSAGEBOX("No object",0+48,"Error" )
FINALLY
  * some cleanup code
ENDTRY
or
* save current error handler
cOrgError = ON("ERROR")

* create dummy error handler
lError = .f.
ON ERROR lError = .t.

* create object
oTest = CREATEOBJECT( "fdfApp.FdfApp" )

* restore original error handler
ON ERROR &cOrgError

* test for error condition
IF lError
  =MESSAGEBOX("No object",0+48,"Error" )
ELSE
  * do something with your object
ENDIF
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform