Gets the type of a WIL variable.
VarType(varname)
(s) varname variable name to check.
(i) type bitmask of type of variable (see below).
This function returns the type of WIL variable that "varname" specifies. The return value will be one or more of the following type flags, combined using the bitwise OR ('|') operator:
Type |
|
Meaning |
-1 |
0xFFFFFFFF |
specified name is a function name, reserved word or string constant |
0 |
0x00000000 |
undefined |
1 |
0x00000001 |
integer |
2 |
0x00000002 |
string |
4 |
0x00000004 |
file handle |
32 |
0x00000020 |
floating point value |
64 |
0x00000040 |
binary buffer |
128 |
0x00000080 |
LPWSTR or "Unicode" |
256 |
0x00000100 |
array |
512 |
0x00000200 |
variant |
1024 |
0x00000400 |
COM/OLE Object |
8192 |
0x00002000 |
64-bit integer |
#DefineFunction CheckBits(bitmask) totalbitmask = bitmask typelist = "" bit = 1 While bitmask ;while there's still a bitmask value If bitmask & bit ;check bit If bit&1 Then typelist = StrCat(typelist,@cr,"Integer(1)") If bit&2 Then typelist = StrCat(typelist,@cr,"String(2)") If bit&4 Then typelist = StrCat(typelist,@cr,"File Handle(4)") If bit&32 Then typelist = StrCat(typelist,@cr,"Floating Point(32)") If bit&64 Then typelist = StrCat(typelist,@cr,"Binary Buffer(64)") If bit&256 Then typelist = StrCat(typelist,@cr,"Array(256)") If bit&512 Then typelist = StrCat(typelist,@cr,"Variant(512)") If bit&1024 Then typelist = StrCat(typelist,@cr,"COM Object(1024)") If bit&8192 Then typelist = StrCat(typelist,@cr,"64-bit Integer(8192)") bitmask = bitmask & ~bit ;decrement working bitmask number by existing byte increments EndIf bit = bit * 2 ;increment byte EndWhile typelist = StrCat(typelist,@cr,"---------------") typelist = StrCat(typelist,@cr,"Total = ",totalbitmask) Return StrTrim(typelist) #EndFunction var1 = 1 Message(StrCat("var1 = ", var1), CheckBits(VarType(var1))) var2 = "abc" Message(StrCat("var2 = ",var2), CheckBits(VarType(var2))) var3 = FileOpen(StrCat(DirWindows(0),"win.ini"),"Read") Message(StrCat("var3 = ",var3), CheckBits(VarType(var3))) FileClose(var3) var4 = 1.1 Message(StrCat("var4 = ",var4), CheckBits(VarType(var4))) var5 = BinaryAlloc(4) Message(StrCat("var5 = ",var5), CheckBits(VarType(var5))) BinaryFree(var5) var6 = ArrDimension(2,2) Message("var6 = {ARRAY}", CheckBits(VarType(var6))) var7 = ObjectCreate("WbemScripting.SWbemLocator") Message(StrCat("var7 = ",var7), CheckBits(VarType(var7))) var8 = 100000000000000 Message(StrCat("var8 = ",var8), CheckBits(VarType(var8))) Exit