Returns the precise variant data type of the specified value represented by a Long corresponding to one of the win32 Variant types (most of which are covered in the Softimage siVariantType enum). This method is for advanced script writers who require more detailed information about the internal representation of a particular variable or value.

In normal scripting the exact type of a variable is not important. For example the string "14" can be used in much the same way as the integer 14 or the double 14.0. In fact, JScript lumps all numeric types into a single umbrella term "number".

All objects, including Softimage Object Model references, will return siDispatch. Use methods like Application.ClassName, SIObject.IsClassOf or SIObject.Type to get more information about the specific type of object.

Internally all scripting variables are represented using the Variant structure. This method returns the value of the "vt" member of that structure. For more details please refer to the win32 documentation of the Variant structure.

C# Syntax

Int32 XSIUtils.GetVariantType( Object in_value );

Scripting Syntax

oReturn = XSIUtils.GetVariantType( Value );

Return Value

One of the values of siVariantType as a Long


Parameter Type Description
Value Variant A scripting variable that needs testing


JScript Example

        This example demonstrates the difference between XSIUtils.GetVariantType
        and the JScript typeof() function.
//INFO : typeof: number VariantType: siInt4
TestJScriptVariable( 49 ) ;
//INFO : typeof: number VariantType: siDouble
TestJScriptVariable( 49.1 ) ;
//INFO : typeof: boolean VariantType: siBool
TestJScriptVariable( true ) ;
//INFO : typeof: string VariantType: siString
TestJScriptVariable( "hello" ) ;
//INFO : typeof: undefined VariantType: siEmpty
TestJScriptVariable( undefined ) ;
//INFO : typeof: object VariantType: VT_NULL
TestJScriptVariable( null ) ;
// All Softimage objects show up as siDispatch
//INFO : typeof: object VariantType: siDispatch
TestJScriptVariable( ActiveSceneRoot ) ;
// So do these standard Automation objects
//INFO : typeof: object VariantType: siDispatch
TestJScriptVariable( new ActiveXObject( "Scripting.FileSystemObject" )) ;
// A JScript array also shows up as siDispatch
//INFO : typeof: object VariantType: siDispatch
TestJScriptVariable( new Array( "1","2","3" )) ;
// A VBScript error shows up differently than a JScript Array
//INFO : typeof: unknown VariantType: VBScript Array (Safearray)
TestJScriptVariable( Application.Workgroups )
// Even code shows up as an object in JScript
//INFO : typeof: function VariantType: siDispatch
TestJScriptVariable( TestJScriptVariable ) ;
function TestJScriptVariable( in_val )
        Application.LogMessage( "typeof: " + typeof(in_val) + " VariantType: " 
                + siVariantTypeToStr( XSIUtils.GetVariantType(in_val) ) );      
function siVariantTypeToStr( in_vt )
        //Demonstrate just the most common
        switch ( in_vt ) {
                case siEmpty : 
                        return "siEmpty";
                case 1 :
                        // 1 == VT_NULL, used by jscript "null"
                        return "VT_NULL";
                case siInt2 :
                        return "siInt2";
                case siInt4 :
                        return "siInt4";
                case siFloat :
                        return "siFloat";
                case siDouble :
                        return "siDouble";
                case siString :
                        return "siString";
                case siBool :
                        return "siBool";
                case siDispatch :
                        return "siDispatch";
                case siUnknown :
                        return "siUnknown";
                case siByte :
                        return "siByte";
                case siUByte :
                        return "siUByte";
                case siUInt2 :
                        return "siUInt2";
                case siUInt4 :
                        return "siUInt4";
                case siUByte :
                        return "siUByte";
                case 8204 :
                        // An array of Variants
                        // 8204 == VT_ARRAY | VT_VARIANT
                        return "VBScript Array (Safearray)"
                default :
                        return in_vt.toString() ;       

See Also

Application.ClassName SIObject.Type