PMC: Object assignment syntax error on succeeding runs

Advanced Macro Recorder/Editor.

Moderator: Pulover

vitronish
Posts: 1
Joined: 17 Jun 2023, 01:42

PMC: Object assignment syntax error on succeeding runs

Post by vitronish » 17 Jun 2023, 02:08

I want to create a function that loads and parses a file with contents similar to an environment file. The run succeeds the first time but succeeding runs throws a syntax error.
The attachment image.png is no longer available

Code: Select all

LoadConfig(location)
{
    obj := Object()
    IfNotExist, %location%
    {
        MsgBox, 0, , File %location% does not exist
        return obj
    }
    Loop, Read, %location%
    {
        parts := StrSplit(A_LoopReadLine, "=", A_Space)
        key := parts[1]
        value := parts[2]
        obj[key] := value
    }
    return obj
}
Attachments
image.png
image.png (10.06 KiB) Viewed 827 times

Return to “Pulovers Macro Creator”