forked from Ixiko/AHK-libs-and-classes-collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIsEmpty.ahk
48 lines (47 loc) · 2.22 KB
/
IsEmpty.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
;
; Function: IsEmpty
; Description:
; Determine whether a variable is considered to be empty.
; Syntax: IsEmpty(var)
; Parameters:
; var - Variable to be checked.
; Return Value:
; Returns FALSE if var has a non-empty and non-zero value.
; The following things are considered to be empty:
; "" (an empty string)
; 0 (0 as an integer)
; "0" (0 as a string)
; [] (an empty array)
; {} (an empty associative array)
; Remarks:
; The function does not work with pseudo-arrays.
; Example:
; x := [0, 1, "0", "1", false, true, [], [1], {}, {k:"V"}]
; for i, testVal in x
; {
; msgbox, 4, "Empty test", % testVal " is " (IsEmpty(testVal) ? "empty." : "not empty.") "`nContinue?"
; IfMsgBox, No
; break
; }
;
IsEmpty(var)
{
if(!IsObject(var))
{
;~ OutputDebug, var is not an object: %var%
if(var = "" || var = 0 || var = "0" || var = false)
return true
else
return false
}
else
{
;~ OutputDebug, % "var is an object, count = " Count(var)
; If any property exists, return false
for k, v in var
{
return false
}
return true
}
}