CallResult
Description
Provides detailed information about the result of a function call.
Discussion
The CallResult object provides detailed information about the result of a function call. For objects that can maintain state across calls (such as SQL::Connection or SQL::Socket), functions often return true (.t.) or false (.f.) indicating success or failure. You can interrogate the object for more information by accessing the CallResult property and its members to get a result code, text, and further information specific to the environment for database and communications objects and functions.
Note: Some functions return CallResult directly. This is especially important when the object is shared by multiple threads or, for some other reason, can't "remember" the result of a previous call. A good example of this is INET::Socket::Accept() which returns a CallResult and a socket (as a reference parameter). This function can be called by several threads at once, so returning true or false would not work, as the object's CallResult property may change between the time you return from the call to Accept() and the time you access the CallResult property.
You can use the CallResult object in your own functions and classes to format more complete status information and return it to callers.
Example
This is the default state of the object.
dim error as CallResult ? error = Canceled = .F. Code = 0 Error = .F. NativeCode = 0 NativeText = "" ReturnDataValue = <No data returned> RowsAffected = 0 StackTrace = "" Success = .T. Text = "Success" TextAndStackTrace = ""
Setting the . Code property also sets the .Text property.
error.code = 815 ? error = Canceled = .F. Code = 815 Error = .T. NativeCode = 0 NativeText = "" ReturnDataValue = <No data returned> RowsAffected = 0 StackTrace = "" Success = .F. Text = "Missing function, name or value" TextAndStackTrace = ""
You may add your own error codes to Alpha5.errors in the reserved range (20000 - 24999).
Properties
- CanceledLogical
Indicates whether the user cancelled the operation.
- CodeNumeric
An Alpha Anywhere error code.
- ErrorLogical
Indicates whether there was an error.
- NativeCodeNumeric
Error code from an underlying class.
- NativeTextCharacter
Error message from an underlying class.
- ReturnDataValueAny Type
Value set by the called function.
- RowsAffectedLogical
Number of data table rows affected by a SQL operation.
- SuccessLogical
Indicates whether the operation succeeded or failed.
- TextCharacter
An error message. This is normally read from Alpha5.errors.
- TextAndStackTraceCharacter
See Also