I am fairly new to ahk and I've run into a bit of a problem. No matter what I try, I cannot get arrays to span multiple lines.
Is this a limitation of AHK itself or is this due to me not understanding the grammar correctly?
An example:
TypeHandler := [
{"pattern": "=[0-z]*", "callback": "HandleEIN"},
{"pattern": "&[0-z]*", "callback": "HandleProduct"}
]
This is slammed by the compiler as not containing recognized actions on the second line, but when I reformat it it works without any issues
TypeHandler := [ {"pattern": "=[0-z]*", "callback": "HandleEIN"}, {"pattern": "&[0-z]*", "callback": "HandleProduct"} ]
Now, this solution does work but it's quite clumsy and really feels like a hack, besides it's a pain to read when the array becomes more than five items long.
I've experimented with simpler arrays too, like
TypeHandler := [ 1, 2, 4, 3 ]
and the issue persists.
I've read through the doc page but there is no mention of a limitation like this.
CodePudding user response:
AHK joins lines that begin with a comma. This isn't perfectly ideal in terms of formatting your data, but it does allow for some level of multi-line arrays for increased readability.
Transformed examples:
;First Example
TypeHandler := [{"pattern": "=[0-z]*", "callback": "HandleEIN"}
,{"pattern": "&[0-z]*", "callback": "HandleProduct"}]
;Second (Simplified) Example
arr := [1
,2
,3]