AHK-v2-script-converter
AHK-v2-script-converter copied to clipboard
Remove key-value obj -> map conversion
V1:
Coord := {X: {X_REAL: 12, X_SUB: 8}, Y: {Y_REAL: 240, Y_SUB: 15}}
MsgBox % Coord.X.X_REAL
For key1, pos in Coord {
For key2, realPos in pos {
MsgBox % key1 ": {" key2 ": " realPos "}"
}
}
V2 (Converted):
Coord := map("X", {X_REAL: 12, "X_SUB", 8), Y: {Y_REAL: 240, Y_SUB: 15}}
MsgBox(Coord.X.X_REAL)
For key1, pos in Coord {
For key2, realPos in pos {
MsgBox(key1 ": {" key2 ": " realPos "}")
}
}
V2 (Expected):
Coord := {X: {X_REAL: 12, X_SUB: 8}, Y: {Y_REAL: 240, Y_SUB: 15}}
MsgBox(Coord.X.X_REAL)
For key1, pos in Coord.OwnProps() {
For key2, realPos in pos.OwnProps() {
MsgBox(key1 ": {" key2 ": " realPos "}")
}
}
While conversion to map fixes for-loops, it breaks Coord.X.X_REAL
Broken for-loops can easily be fixed by appending .OwnProps()
Current obj->map conversion doesn't work with nested objs, not converting at all will easily fix