Boolean = IsError(Variant)
Requires: Variants.lg32
Variant = CVErr(errorvalue%)
errorvalue% = CVErrRead(Variant)
The Error type can be used to indicate an error has occured or can be used to indicate that the Variant is of a custom or non-standard type, such as Missing.
Error values are created in Visual Basic by converting real numbers to error values using the CVErr function. The IsError function is then used to determine if a numeric expression represents an error. IsError returns True if the expression argument indicates an error; otherwise, it returns False.
GFA-BASIC 32 does not natively support CVErr, but from version 2.58, both CVErr and a function to read error values in variants - CVErrRead - can be accessed through the Variants Library.
$Library "Variants.lg32"
Print IsError(test("String"))
Print "Error Number: "; CVErrRead(test("String"))
Print IsError(test(6))
Print "Error Number: "; CVErrRead(test(6))
Print IsError(test())
Print "Error Number: $"; Hex(CVErrRead(test()), 8) // The Error Number of the Missing value
FunctionVar test(Optional param1)
If IsMissing(param1) : test = Missing // If no parameter passed, return Missing
Else If Not IsNumeric(param1) : test = CVErr(2001) // Sets a custom error number 2001 to the return value
Else : test = param1
EndIf
EndFunction
IsDate, IsEmpty, IsMissing, IsNull, IsNumeric, IsObject
{Created by Sjouke Hamstra; Last updated: 23/08/2020 by James Gaite}