When I call :
[color=#107095]if[/color] !(myDic[[color=#666666]"mykey"[/color]])
if there is no key "mykey" in myDic, it is created with no value.
Please stick with "PG-13" or less rated object names. This issue is that the dictionary object creates the key is called.
The problem is mainly with numeric keys.
This is an issue with AHK converting everything to a string. On the AHK V2 roadmap:
• Change the way types are handled so that numbers can be distinguished from numeric strings. This also means that the format of a numeric literal such as 0x10 will be discarded and floating-point literals such as 1.0 will be pre-converted to binary (64-bit floating-point) format, rather than being stored as strings.
CSobj() {
[color=#107095]static[/color] base := [color=#107095]object[/color]([color=#666666]"_NewEnum"[/color],[color=#666666]"__NewEnum"[/color], [color=#666666]"Next"[/color],[color=#666666]"__Next"[/color], [color=#666666]"__Set"[/color],[color=#666666]"__Setter"[/color], [color=#666666]"__Get"[/color],[color=#666666]"__Getter"[/color])
[color=#107095]return[/color], [color=#107095]object[/color]([color=#666666]"__sd_obj__"[/color], [color=#107095]ComObjCreate[/color]([color=#666666]"Scripting.Dictionary"[/color]), [color=#666666]"base"[/color], base)
}
__Getter(self, key) {
[color=#107095]if[/color] self.__sd_obj__.exists(key)
[color=#107095]return[/color], self.__sd_obj__.item(key)
}
__Setter(self, key, value) {
self.__sd_obj__.item(key) := value
[color=#107095]return[/color], false
}
__NewEnum(self) {
[color=#107095]return[/color], self
}
__Next(self, ByRef key = [color=#666666]""[/color], ByRef val = [color=#666666]""[/color]) {
[color=#107095]static[/color] Enum
[color=#107095]if[/color] not Enum
Enum := self.__sd_obj__._NewEnum
[color=#107095]if[/color] Not Enum[key]
[color=#107095]return[/color], Enum:=false
[color=#107095]else[/color],
val := self[IsStr(key)? key [color=#666666]""[/color]:key]
[color=#107095]return[/color], true
}
IsStr(in) {
Format := [color=brown]A_FormatInteger[/color]
[color=#107095]SetFormat[/color], IntegerFast, Hex
out := [color=#107095]SubStr[/color](in:=in, 1, 2)=[color=#666666]"0x"[/color]? False:True
[color=#107095]SetFormat[/color], IntegerFast, %Format%
[color=#107095]return[/color], out
}