-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathvtype.ahk
25 lines (21 loc) · 838 Bytes
/
vtype.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
vtype(v, assert:="")
{
static is_v2 := A_AhkVersion >= "2"
static Type := is_v2 ? Func("Type") : ""
static nMatchObj := is_v2 ? "" : NumGet(&(m, RegExMatch("", "O)", m)))
static nBoundFunc := NumGet(&(f := Func("Func").Bind()))
static nFileObj := NumGet(&(f := FileOpen("*", "w")))
if is_v2
t := %Type%(v) ;// use v2.0-a built-in Type()
else if IsObject(v)
t := ObjGetCapacity(v) != "" ? "Object"
: IsFunc(v) ? "Func"
: ComObjType(v) != "" ? "ComObject"
: NumGet(&v) == nBoundFunc ? "BoundFunc"
: NumGet(&v) == nMatchObj ? "RegExMatchObject"
: NumGet(&v) == nFileObj ? "FileObject"
: "Property"
else
t := ObjGetCapacity([v], 1) != "" ? "String" : (InStr(v, ".") ? "Float" : "Integer")
return assert ? InStr(t, assert) : t
}