udfCheckVarType
str udfCheckVarTypeV1 (int)
str udfCheckVarTypeV2 (int)
str udfCheckVarTypeV3 (int)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfCheckVarTypeV1 (intBitmask)
strListTypes = "VarType = " : intBitmask : @LF
intBit = 1
While intBitmask  ; While there is still a bitmask value.
   If intBitmask & intBit ; Check bit.
      If intBit & 1 Then strListTypes = strListTypes : @LF : "Integer (1)"
      If intBit & 2 Then strListTypes = strListTypes : @LF : "String (2)"
      If intBit & 4 Then strListTypes = strListTypes : @LF : "File Handle (4)"
      If intBit & 32 Then strListTypes = strListTypes : @LF : "Floating Point (32)"
      If intBit & 64 Then strListTypes = strListTypes : @LF : "Binary Buffer (64)"
      If intBit & 256 Then strListTypes = strListTypes : @LF : "Array (256)"
      If intBit & 512 Then strListTypes = strListTypes : @LF : "Variant (512)"
      If intBit & 1024 Then strListTypes = strListTypes : @LF : "COM Object (1024)"
      intBitmask = intBitmask & ~intBit ; Decrement current bitmask number by current bit.
   EndIf
   intBit = intBit << 1 ; Increment bit.
EndWhile
Return strListTypes
; (c)Detlev Dalitz.20120705.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfCheckVarTypeV2 (intBitmask)
strListTypes = "VarType = " : intBitmask : @LF
intBit = 1
While intBitmask  ; While there is still a bitmask value.
   If intBitmask & intBit ; Check bit.
      If intBit & 1
         strListTypes = strListTypes : @LF : "Integer (1)"
      ElseIf intBit & 2
         strListTypes = strListTypes : @LF : "String (2)"
      ElseIf intBit & 4
         strListTypes = strListTypes : @LF : "File Handle (4)"
      ElseIf intBit & 32
         strListTypes = strListTypes : @LF : "Floating Point (32)"
      ElseIf intBit & 64
         strListTypes = strListTypes : @LF : "Binary Buffer (64)"
      ElseIf intBit & 256
         strListTypes = strListTypes : @LF : "Array (256)"
      ElseIf intBit & 512
         strListTypes = strListTypes : @LF : "Variant (512)"
      ElseIf intBit & 1024
         strListTypes = strListTypes : @LF : "COM Object (1024)"
      EndIf
      intBitmask = intBitmask & ~intBit ; Decrement current bitmask number by current bit.
   EndIf
   intBit = intBit << 1 ; Increment bit.
EndWhile
Return strListTypes
; (c)Detlev Dalitz.20120705.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfCheckVarTypeV3 (intBitmask)
strListTypes = "VarType = " : intBitmask : @LF
intBit = 1
While intBitmask  ; While there is still a bitmask value.
   If intBitmask & intBit ; Check bit.
      Switch @TRUE
      Case !!(intBit & 1)
         strListTypes = strListTypes : @LF : "Integer (1)"
         Break
      Case !!(intBit & 2)
         strListTypes = strListTypes : @LF : "String (2)"
         Break
      Case !!(intBit & 4)
         strListTypes = strListTypes : @LF : "File Handle (4)"
         Break
      Case !!(intBit & 32)
         strListTypes = strListTypes : @LF : "Floating Point (32)"
         Break
      Case !!(intBit & 64)
         strListTypes = strListTypes : @LF : "Binary Buffer (64)"
         Break
      Case !!(intBit & 256)
         strListTypes = strListTypes : @LF : "Array (256)"
         Break
      Case !!(intBit & 512)
         strListTypes = strListTypes : @LF : "Variant (512)"
         Break
      Case !!(intBit & 1024)
         strListTypes = strListTypes : @LF : "COM Object (1024)"
      EndSwitch
      intBitmask = intBitmask & ~intBit ; Decrement current bitmask number by current bit.
   EndIf
   intBit = intBit << 1 ; Increment bit.
EndWhile
Return strListTypes
; (c)Detlev Dalitz.20120705.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

intNum = 1537
Pause ("udfCheckVarTypeV1", udfCheckVarTypeV1 (VarType (intNum))) ; "Integer (1)"
Pause ("udfCheckVarTypeV2", udfCheckVarTypeV2 (VarType (intNum))) ; "Integer (1)"
Pause ("udfCheckVarTypeV3", udfCheckVarTypeV3 (VarType (intNum))) ; "Integer (1)"


strText = "Test"
Pause ("udfCheckVarTypeV2", udfCheckVarTypeV2 (VarType (strText))) ; "String (2)"


strFloat = 3.14
Pause ("udfCheckVarTypeV2", udfCheckVarTypeV2 (VarType (strFloat))) ; "Floating Point (32)"


arrArray = Arrayize ("1,a,2,b,3,c", ",")
Pause ("udfCheckVarTypeV2", udfCheckVarTypeV2 (VarType (arrArray))) ; "Array (256)"
Pause ("udfCheckVarTypeV2", udfCheckVarTypeV2 (VarType (arrArray[0]))) ; "String (2)"
Pause ("udfCheckVarTypeV2", udfCheckVarTypeV2 (VarType (arrArray[1]))) ; "String (2)"


objShell = ObjectCreate ("WScript.Shell")
Pause ("udfCheckVarTypeV2", udfCheckVarTypeV2 (VarType (objShell))) ; "Integer (1)" + "Variant (512)" + "COM Object (1024)"

strFolder = objShell.SpecialFolders.Item("Desktop") ; VT BSTR.
Pause ("udfCheckVarTypeV2", udfCheckVarTypeV2 (VarType (strFolder))) ; "Variant (512)"
Pause ("udfCheckVarTypeV2", udfCheckVarTypeV2 (VarType (objShell.SpecialFolders))) ; -1 ... specified name is a function name, reserved word or string constant.

:CANCEL
objShell = 0
Exit