Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to generate an error in calling program
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00699719
Message ID:
00699735
Views:
15
>Hi,
>
>I need to check return values of many API function calls within class. In order to simplify this task I have the following idea: assign a return value to a property of a class and test a value in Assign method for that property.
>
>Define Class test as Custom
>	Protected RetVal
>	Protected Procedure RetVal_Assign(tnRetVal)
>		If tnRetVal != 0
>			Error "Error #" + Trans(tnRetVal)
>		EndIf
>	EndProc
>	Procedure SomeMethod()
>		This.RetVal = SomeAPIFunction()
>	EndProc
>EndDefine
>
>However this code will generate an error within line with Error statement, but I want to generate an error within line where API function is called. Any ideas?

The problem you face is that no VFP error is actually created by the vast majority of API call error returns, so there's nothing to catch the error spontaneously. Further, not all API functions return a consistent value for - in some cases, a 0 represents ERROR_SUCCESS, other times, it indicates a failure. You have to code each API call separately.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform