Purpose |
Return the Windows API error code of the most recent PowerBASIC run-time error, or internal call to the Windows API. |
Syntax |
y = ERRAPI |
Remarks |
A number of statements in the PowerBASIC language make calls to the Win32 API. For example, the OPEN statement calls the OpenFile API. If an error occurs in the API call, that error code will be available with the ERRAPI system variable. However, some statements may make multiple calls to the API, and the results can affect the ERRAPI result. For example, temporary string allocations may occur when passing a literal string or expression to an API, and the subsequent memory deallocation may cause the API result code from the "core" API function to be lost. Because of this, it is not always possible for ERRAPI to report a meaningful result code. Like the ERR system variable, the value contained in ERRAPI is not reset when a successful PowerBASIC statement is executed. ERRCLEAR will clear both the run-time error code in ERR as well as the API error code in ERRAPI. |
Restrictions |
ERRAPI has been deemed obsolete, and is expected to be discontinued in subsequent versions of PowerBASIC. On this basis, continued use of ERRAPI is not recommended. |
See also |
ERL, ERR, ERRCLEAR, ERROR$, Error Overview, Error Trapping, ON ERROR, Run-time Errors |
Example |
OPEN "\\MYSERVER\MYFILE.TXT" FOR INPUT AS #1 IF ERR = 53 THEN 'file not found IF ERRAPI = 67 THEN Msg$ = "Bad network name" END IF END IF |