I'm working on code to extract attributes from XML then store them in an assoc. array as key/value pairs for use elsewhere in my code.
The XML is written by others, so may not always contain attributes I expect, therefore I will end up with "missing" keys in my array object,
I'm ok with this as I will just use default values where the XML failed to specify them.
Questions:
1. Is there a preferred "pattern" for defaulting values when a key can't be found in an object? *see code below for my thinking
2. Why does AHK fail so silently in the case of missing keys? Is there anything that can be done about this?
*Is there a clean and readable way of doing the following or is this optimal?
Code: Select all
o := {carmen:"San Diego"}
;Extract some values from object, Default to "not found if key if missing from object
c := o.carmen ? o.carmen : "not found"
w := o.wally ? o.wally : "not found"
msgbox % "Carmen:"c "`nWally:"w