This repository has been archived by the owner on May 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dictionary_UDF.au3
189 lines (146 loc) · 8.77 KB
/
Dictionary_UDF.au3
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#cs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Name..................: Dictionary_UDF
Description...........: Dictionary basic functions: object that stores data key/item pairs
Documentation.........: https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/dictionary-object
Author................: [email protected]
Modified..............: 2019-12-30
Version...............: v1.0
#ce ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include-once
#Region FUNCTIONS_LIST
#cs ===================================================================================================================================
_Dictionary_Create()
_Dictionary_AddItem($_objDictionary, $_sKey, $_sValue)
_Dictionary_SetItemValue($_objDictionary, $_sKey, $_sValue)
_Dictionary_GetItemValue($_objDictionary, $_sKey)
_Dictionary_KeyExists($_objDictionary, $_sKey)
_Dictionary_ListItems($_objDictionary)
_Dictionary_ListKeys($_objDictionary)
_Dictionary_RemoveItem($_objDictionary, $_sKey)
_Dictionary_RemoveAll($_objDictionary)
#ce ===================================================================================================================================
#EndRegion FUNCTIONS_LIST
#Region FUNCTIONS
#cs #FUNCTION# ====================================================================================================================
Name...............: _Dictionary_Create()
Description .......: Creates Scripting.Dictionary object
Return values .....: Success - Dictionary object
Failure - FALSE; @error
Author ............: [email protected]
Modified...........: 2019-12-04
#ce ===============================================================================================================================
Func _Dictionary_Create()
Local $_objDictionary = ObjCreate('Scripting.Dictionary')
If NOT IsObj($_objDictionary) Then Return SetError(1, 0, False)
Return $_objDictionary
EndFunc
#cs #FUNCTION# ====================================================================================================================
Name...............: _Dictionary_AddItem
Description .......: Adds a key and item pair to a Dictionary object
Return values .....: Success - TRUE
Failure - FALSE; @error
Author ............: [email protected]
Modified...........: 2019-12-04
#ce ===============================================================================================================================
Func _Dictionary_AddItem($_objDictionary, $_sKey, $_sValue)
If NOT IsObj($_objDictionary) Then Return SetError(1, 0, False)
If $_sKey = "" Then Return SetError(2, 0, False)
If $_objDictionary.Exists($_sKey) Then Return SetError(3, 0, False)
$_objDictionary.Add($_sKey, $_sValue)
Return True
EndFunc
#cs #FUNCTION# ====================================================================================================================
Name...............: _Dictionary_SetItemValue($_objDictionary, $_sKey, $_sValue)
Description .......: Sets item value in Scripting.Dictionary object
Return values .....: Success - TRUE
Failure - FALSE; @error
Author ............: [email protected]
Modified...........: 2019-12-04
#ce ===============================================================================================================================
Func _Dictionary_SetItemValue($_objDictionary, $_sKey, $_sValue)
If NOT IsObj($_objDictionary) Then Return SetError(1, 0, False)
If $_sKey = "" Then Return SetError(2, 0, False)
If NOT $_objDictionary.Exists($_sKey) Then Return SetError(3, 0, False)
$_objDictionary.Item($_sKey) = $_sValue
Return True
EndFunc
#cs #FUNCTION# ====================================================================================================================
Name...............: _Dictionary_GetItemValue($_objDictionary, $_sKey)
Description .......: Gets item value from Scripting.Dictionary object
Return values .....: Success - Item value
Failure - FALSE; @error
Author ............: [email protected]
Modified...........: 2019-12-04
#ce ===============================================================================================================================
Func _Dictionary_GetItemValue($_objDictionary, $_sKey)
If NOT IsObj($_objDictionary) Then Return SetError(1, 0, False)
If $_sKey = "" Then Return SetError(2, 0, False)
If NOT $_objDictionary.Exists($_sKey) Then Return SetError(3, 0, False)
Return $_objDictionary.Item($_sKey)
EndFunc
#cs #FUNCTION# ====================================================================================================================
Name...............: _Dictionary_KeyExists($_objDictionary, $_sKey)
Description .......: Returns True if a specified key exists in the Dictionary object; False if it does not.
Return values .....: Success - TRUE or FALSE
Failure - FALSE; @error
Author ............: [email protected]
Modified...........: 2019-12-30
#ce ===============================================================================================================================
Func _Dictionary_KeyExists($_objDictionary, $_sKey)
If NOT IsObj($_objDictionary) Then Return SetError(1, 0, False)
If $_sKey = "" Then Return SetError(2, 0, False)
Return $_objDictionary.Exists($_sKey)
EndFunc
#cs #FUNCTION# ====================================================================================================================
Name...............: _Dictionary_ListItems($_objDictionary)
Description .......: Returns an array containing all the items in a Dictionary object
Return values .....: Success - Array
Failure - FALSE; @error
Author ............: [email protected]
Modified...........: 2019-12-30
#ce ===============================================================================================================================
Func _Dictionary_ListItems($_objDictionary)
If NOT IsObj($_objDictionary) Then Return SetError(1, 0, False)
Return $_objDictionary.Items
EndFunc
#cs #FUNCTION# ====================================================================================================================
Name...............: _Dictionary_ListKeys($_objDictionary)
Description .......: Returns an array containing all existing keys in a Dictionary object
Return values .....: Success - Array
Failure - FALSE; @error
Author ............: [email protected]
Modified...........: 2019-12-30
#ce ===============================================================================================================================
Func _Dictionary_ListKeys($_objDictionary)
If NOT IsObj($_objDictionary) Then Return SetError(1, 0, False)
Return $_objDictionary.Keys
EndFunc
#cs #FUNCTION# ====================================================================================================================
Name...............: _Dictionary_RemoveItem($_objDictionary, $_sKey)
Description .......: Removes a key/item pair from a Dictionary object
Return values .....: Success - TRUE
Failure - FALSE; @error
Author ............: [email protected]
Modified...........: 2019-12-30
#ce ===============================================================================================================================
Func _Dictionary_RemoveItem($_objDictionary, $_sKey)
If NOT IsObj($_objDictionary) Then Return SetError(1, 0, False)
If $_sKey = "" Then Return SetError(2, 0, False)
If NOT $_objDictionary.Exists($_sKey) Then Return SetError(3, 0, False)
$_objDictionary.Remove($_sKey)
Return True
EndFunc
#cs #FUNCTION# ====================================================================================================================
Name...............: _Dictionary_RemoveAll($_objDictionary)
Description .......: Removes all key, item pairs from a Dictionary object
Return values .....: Success - TRUE
Failure - FALSE; @error
Author ............: [email protected]
Modified...........: 2019-12-30
#ce ===============================================================================================================================
Func _Dictionary_RemoveAll($_objDictionary)
If NOT IsObj($_objDictionary) Then Return SetError(1, 0, False)
$_objDictionary.RemoveAll
Return True
EndFunc
#EndRegion FUNCTIONS