8 27 Variant Handling

LANSA Technical

8.27 Variant Handling

A Function Library is a component that contains a set of routines defined using the MthRoutine command. (Refer to 8.26 Function Libraries.) These function library routines can be used in expressions. To handle objects of type *VARIANT, you need to use the variant function library #PRIM_LIBV. (For string, number, date and time, using Intrinsic Functions is simpler than using a function library. )

Variants can contain any type of data (strings, integers, decimals, booleans, components). You can use variant functions for testing the kind of value contained in the variable and you can retrieve its value in converted forms like numbers, strings or booleans.

Variants make possible the generic processing of values regardless of their type. For example, the value of a grid cell cannot be known by the compiler before the application is executed. Therefore the Value parameter of grid EditorChanged and ItemChangedAccept events returns the value in the cell as a variant so that compiler errors about the declared type of the value do not occur. You then need to write the program in a way that understands what type(s) are in the grid.

Also the EditorChanged and ItemChangedAccept events of tree and list views return the Value parameter as a variant. Similarly, many ActiveX controls return and accept values as variants. You can also use variants in your own dynamic programs for generic processing of values regardless of their type. For example:

Define_Com Class(*VARIANT) Name(#lclVariant)
 

Using the *VARIANT class is the recommended approach. Alternatively, you can use primitive variant component #PRIM_VAR and its properties and methods.

#PRIM_LIBV supports these functions:

8.27.1 VarAsBoolean

8.27.8 VarIsNull

8.27.2 VarAsDecimal

8.27.9 VarIsNullReference

8.27.3 VarAsInteger

8.27.10 VarIsNumber

8.27.4 VarAsReference

8.27.11 VarIsReference

8.27.5 VarAsString

8.27.12 VarIsString

8.27.6 VarIsBoolean

8.27.13 VarType

8.27.7 VarIsEmpty

 

 

Also See

8.26 Function Libraries

Intrinsic Functions

Ý 8. RDMLX Commands and RDMLX Features