AHK-v2-script-converter icon indicating copy to clipboard operation
AHK-v2-script-converter copied to clipboard

Remove key-value obj -> map conversion

Open Banaanae opened this issue 6 months ago • 0 comments

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

Banaanae avatar Jul 29 '24 04:07 Banaanae