error$
Syntax
result = ERROR$ (errorcode)
Arguments
result: text
errorcode: numeric
Meaning
The function error$(errorcode) provides extra information about the last generated error code of any ADAPL function. This information consists of data generated by the software, such as the name of the database that couldn’t be opened or the name of an index that appears corrupted. (So no text file is used.) The last generated error code of FACS operations is kept in the FACS result code &E, while of other ADAPL functions you may obtain the result (error) code of the executed function by assigning the function call to a numerical variable, like so: result = <ADAPL function call>: the call will be executed normally, but the result will be stored in the variable (which you do have to declare first, like other custom variables).
Example 1
In adapls you can display the result of error$(&E) in an error message for the user or system administrator, next to the error code itself:
open document
if (&E) {
errorm 'Error ' + &E + 'Details: ' + error$ (&E)
} else {
errorm 'No error '
}
Result
If during opening of the dataset no error occurs, then the message No error will be shown. If an error does occur, then the error code is displayed, preceded by the word Error and followed by Details: and the extra error information.
Example 2
To display not only the result code of a non-FACS ADAPL function like WordCreateDocument, but some extra information as well, you could use code similar to the following:
result = WordCreateDocument (‘c:\mydot.dot’, ‘c:\test.doc’, 1)
errorm 'Result code: ' + result + '. Details: ' + error$(val(result))
Result
Result codes higher than zero represent an error.
Note that because error$ requires a numerical value while result codes might not always be numericals, you can use the val function on the result code to convert it to a numerical value.