Purpose |
Returns a status code (hResult) to describe the success or failure of the most recent METHOD or PROPERTY procedure. |
Syntax |
lResult& = OBJRESULT |
Remarks |
An Automation procedure is a METHOD or PROPERTY on an IAUTOMATION, IDISPATCH, or DUAL interface. By definition, an Automation procedure always returns a hidden result code which is cryptically called an hResult. OBJRESULT the most recent hResult generated by the program, and can be used to identify the success or failure of an operation. If an Automation procedure fails with a severe error, the ERR system variable is set to an appropriate PowerBASIC error code. This is usually Error 99 ("Object error"). In such cases, you can use the OBJRESULT function to return the result (hResult&) of the last run-time OBJECT statement or direct METHOD/PROPERTY reference. Numeric equates for most OBJRESULT errors can be found in the WIN32API.INC file, and are mostly prefixed with %E_, %CO_, %OLE_, and %DISP_. The following list includes the most common codes that may be returned by a direct call of a Method or Property: %S_OK =
&H0 This list tells the most common status codes which may be returned by a DISPATCH call using the OBJECT statement: %S_OK =
&H0 If the status code %DISP_E_EXCEPTION is returned, you can use the IDISPINFO object to secure much additional information about the status. This includes a more specific error code, a description, help file information, etc. If the status code %DISP_E_PARAMNOTFOUND or %DISP_E_TYPEMISMATCH, you can use IDISPINFO.PARAM to determine which parameter actually caused the problem. Please refer to the IDISPINFO section for more details. As can be seen from the above lists, a large numeric status code can be cryptic. However, you can translate the OBJRESULT code into a descriptive message using the OBJRESULT$ function. This can be most helpful, especially during application development and debugging. |
Restrictions |
Methods and Properties on a custom interface (a direct interface based upon IUnknown rather than IDispatch) do not support OLE Automation, and do not return an OBJRESULT (hResult). |
See also |
DIM, CLASS, CLSID$, IDISPINFO, GUID$, GUIDTXT$, INTERFACE (Direct), INTERFACE (IDBind), ISINTERFACE, ISNOTHING, ISOBJECT, LET (with Objects), METHOD, PROPERTY, OBJECT, OBJACTIVE, OBJEQUAL, OBJPTR, OBJRESULT$, PROGID$, What is an hResult?, What is an object, anyway? |