@Helgef. Btw I want to be able to use any string as a key name, so I think that this requires Object() aka {}, not Array() aka [].
I'm trying to convert the class from one syntax to another. I had hoped/expected this could be done with the method-based class looking pretty much identical to the function-based class.
==================================================
Goals: secondary 'reference'/'auxiliary' objects within classes.
One thing I'm not sure about is if it's possible to create additional objects within a class that all methods can refer to, or whether you are limited to one object within a class, and thus would have to use subkeys of that object to assist you.
In a worst-case scenario, perhaps I could have a global object, that all objects that I create from a custom class could use. And keep each object's content in a subkey of the global object, perhaps deriving the subkey's name from each object's address offset.
==================================================
Goals: enumerators.
Enumerators have been giving me the most trouble regarding objects, unfortunately of the few straightforward examples I've found, they relate to integers, or use function syntax, or have other issues like the 'i' variable in the example here, where I'm unsure where it came from.
==================================================
Btw.
Two key bits of knowledge about objects, that I only fully realised were true yesterday, and that I think are the main obstacle holding everybody back:
__Get / __Set / __Call only take place for a key that does not yet exist. Thus ideally, the key *never* exists, and you can take advantage of the __Get/__Set/__Call meta-functions for special purposes, and you use a secondary object if possible, to store everything.
Objects
https://autohotkey.com/docs/Objects.htm#Meta_Functions
Meta-functions define what happens when a key is requested but not found within the target object.
__Set:
- If there is a 'return' line (it doesn't matter what is returned), this prevents AHK from automatically adding 'key := value' to the object.
- Trying to set a new key's value within a __Set method, will trigger __Set, potentially resulting in an infinite loop. Use a function such as ObjRawSet to bypass this and manually add in a key.
==================================================
Goals:
- acquire the last bits of knowledge I need to complete my objects tutorial (including converting between function syntax and method syntax):
jeeswg's objects tutorial (not yet complete) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=29232
cf. my RegEx tutorial:
RegEx handy examples (RegExMatch, RegExReplace) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=28031
- a class where a key name that looks numeric is treated as a string
- 4 types of array: CSA CSD CIA CID (case (in)sensitive, keys returned in alphabetical/creation date order)
CIA would be a standard AHK object (plus treat all key names as strings, never numeric, plus have a count keys method)
CIS is basically the ordered array
CSD is basically a Scripting.Dictionary object
CSA would use a Scripting.Dictionary object
see:
case sensitive/case insensitive arrays (maintain key order, no key autosort) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=29198
- add a count method to custom classes to state how many keys it has
Other goals:
- a custom class that works like a normal class (as a basis for slight modifications to the standard AHK object)
- a class that returns items in reverse alphabetical order
- a class that returns items skipping some (e.g. get every nth item)
- a class where each item can have both children and its own value (like a treeview control)
- a class where you can return an object's parent
Other object tutorial goals:
- tips on converting code using COM.ahk's functions to AHK's native COM
- tips on converting code from other programming languages to AHK's native COM
Basically I want to stop spending time researching AHK's objects, so that I can move onto and finish other AHK and AHK-related projects.