STATUS() |
|
|
The STATUS() function returns information following execution of certain other statements. In many cases, this information gives details of an error condition.
Format
STATUS()
The STATUS() function is used to fetch status information set by other statements as documented in their descriptions. Where the value relates to an error condition and except as stated in the documentation for specific functions, the value returned by STATUS() will correspond to one of the tokens in the ERR.H record of the SYSCOM file. For best readability of QMBasic source code it is strongly recommended that applications testing for a specific error code should use the token name rather than the actual value of error code.
The STATUS() function can be used any number of times to retrieve the current status value but this value may be changed by other statements. In general, the STATUS() function should be used as close as possible to the statement that set the value to be retrieved. In particular, use of CALL and EXECUTE are very likely to result in execution of statements that destroy the previous value of the STATUS() function.
There is a standard subroutine, !ERRTEXT(), that can be used to translate an error number to an equivalent text message.
See the OS.ERROR() function for a way to access operating system level error numbers.
Example
OPEN "STOCK.FILE" TO FVAR ELSE ABORT "Open failed : Error code " : STATUS() END
This program fragment attempts to open a file and, if the OPEN fails, reports the error code. |