Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.4j

Application v 5.22b

  

 

Chapter FiveGeneral Functions (continued)

IsError Function

IsNotError Function

Overview

The IsError and IsNotError functions test if a value matches a formatted Legato error code or a string error condition or an invalid handle value.

Syntax/Parameters

Syntax

boolean = IsError    ( [ mixed data] );

boolean = IsNotError ( [ mixed data] ); 

Parameters

data

An optional int, dword, 8/16 string as value, or a handle. See remarks for tests. If omitted, the “last error” value is used as the error code value.

Return Value

For IsError, returns TRUE if data matches an error condition or FALSE if it does not.

For IsNotError, returns FALSE if data matches an error condition or TRUE if it does not.

Remarks

Depending on the data type, the IsError and IsNotError functions check for an error condition. This is useful for checking the results of an SDK function call or even a script function call if it follows the Legato standard error rules.

When the data parameter contains an integer, the functions test if the integer matches an 0x80000000 error code set, which includes all defined Legato error codes. Other error codes, such as those from different DLLs, are not supported. Note that some APIs may use 0 as an error code. It is therefore always important to validate return codes against the defined error codes of the API in question. Note that -1 may also match non-Legato error codes; certain functions that return 64 bit integers may return an error on a bitwise match.

For strings, if the string is empty (a zero length string) and the last error condition (the code retrieved with the GetLastError function) matches a formatted error code, the function returns passes. In this mode, the IsError and IsNotError functions rely on the last error condition which will be reset when most other API function are called. Programmers are cautioned to only use the IsError(string) or IsNotError(string) function construct immediately after the function to be tested.

For handles, the value is tested for NULL_HANDLE (0) or INVALID_HANDLE_VALUE (0xFFFFFFFF). For non-Legato object handles, NULL_HANDLE can be valid. For example, the Windows SDK CreateFile function can return 0 as a valid handle. Programmers are advised to use caution when using the IsError(handle) or IsNotError(handle) function with non-Legato handles.

When using the GetLastError function to retrieve and test an error with IsError or IsNotError, the function may not operate as expected on all return values since some last errors are raw base codes, such as 2, for FILE_NOT_FOUND. This is because the return value is not a formatted error code.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic