EnglishРусский  
The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

VARIANT

VARIANT type. VARIANT is a universal type that is used for storing various data and it enables different programs to exchange data properly. This type represents a structure consisted of two main fields: the first field is a type of the stored value, the second field is the stored value or the pointer to a storage area. The VARIANT type is defined as follows:

type VARIANT {
   ushort vt          
   ushort wReserved1     
   ushort wReserved2     
   ushort wReserved3 
   ulong  val
 }

vt is a type code of the contained value ( type constants VT_*: $VT_UI4, $VT_I4, $VT_BSTR ... );
val is a field used for storing values

The library provides only some of the operations of the VARIANT type, however, you can use the fields of the given structure. The example illustrates creation of the VARIANT( VT_BOOL ) variable:

VARIANT bool
....
bool.clear()
bool.vt = $VT_BOOL
(&bool.val)->uint = 0xffff// 0xffff - VARIANT_TRUE

This example shows VARIANT operations

uint val
str  res
oleobj ActWorkSheet
VARIANT vval

....
vval = int( 100 )        //VARIANT( VT_I4 ) is being created
excapp~Cells(1,1) = vval //equals excapp~Cells(1,1) = 100
                        
vval = "Test string"     //VARIANT( VT_BSTR ) is being created
excapp~Cells(2,1) = vval //equals excapp~Cells(1,1) = "Test string"

val = uint( excapp~Cells(1,1)~Value ) //VARIANT( VT_I4 ) is converted to uint 
res = excapp~Cells(2,1)~Value         //VARIANT( VT_BSTR ) is converted to str
ActWorkSheet = excapp~ActiveWorkSheet //VARIANT( VT_DISPATCH ) is converted 
 to oleobj

Related links

Source