Several AutoLISP functions allow you to create and work with variants:
vlax-make-variant function accepts two arguments: value and type. The value argument is the value to be assigned to the variant. The type argument specifies the type of data to be stored in the variant. For type, specify one of the following constants:
TheUninitialized (default value)
Contains no valid data
Integer
Long integer
Single-precision floating-point number
Double-precision floating-point number
String
Object
Boolean
Array
The constants evaluate to integer values. Because the integer values can change, you should always refer to the constant, not the integer value. See the entry for vlax-make-variant in the AutoLISP Reference for the current integer value assigned to each constant.
For example, the following function call creates an integer variant and sets its value to 5:
_$ (setq varint (vlax-make-variant 5 vlax-vbInteger))
#<variant 2 5>
vbInteger) and the variant's value (5).
The return value indicates the variant's data type (2, which isvlax-make-variant, the function assigns a default type. For example, the following function call creates a variant and assigns it a value of 5 but does not specify a data type:
If you do not specify a data type to_$ (setq varint (vlax-make-variant 5))
#<variant 3 5>
vlax-make-variant assigned the specified integer value to a Long Integer data type, not Integer, as you might expect. When assigning a numeric value to a variant, you should explicitly state the data type you want. Refer to vlax-make-variant in the AutoLISP Reference for a complete list of default type assignments.
By default,vlax-make-variant allocates an uninitialized (vlax-vbEmpty) variant.
If you do not specify a value or data type,