Syntax issue, associative array with string key and command

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
mslonik
Posts: 144
Joined: 21 Feb 2019, 04:38
Location: Poland
Contact:

Syntax issue, associative array with string key and command

10 Apr 2021, 09:09

Dear forum,

I cannot by myself figure out what I'm doing wrong:

Code: Select all

ini_ListViewPos := {"X": 0, "Y": 0, "W": 0, "H": 0}

ini_ListViewPos["X"] := 7 ;this works

IniRead, ini_ListViewPos["X"],				Config.ini, Section, Key ;this doesn't work
I get the following message:
The following variable name contains an illegal character: "ini_ListViewPos["X"]"

What I'd like to get is:

Code: Select all

ini_ListViewPos["X"] <- Key
I have a problem with syntax. How should I use command (e.g. IniRead) with associative array (e.g. ini_ListViewPos) when keys of that associative array are strings?

Kind regards, mslonik

My scripts on this forum: Hotstrings Diacritic O T A G L E
Please become my patreon: Patreon👍
Written in AutoHotkey text replacement tool: Hotstrings.technology
Courses on AutoHotkey :ugeek:
User avatar
mikeyww
Posts: 26931
Joined: 09 Sep 2014, 18:38

Re: Syntax issue, associative array with string key and command

10 Apr 2021, 09:23

I'm not sure that you can specify an array as an output variable, but you can use an intermediate variable.
gregster
Posts: 9012
Joined: 30 Sep 2013, 06:48

Re: Syntax issue, associative array with string key and command

10 Apr 2021, 09:24

Afaik, this is not supported for commands that return a outputvariable. As a workaround, you'll have to use a regular variable and then assign it to an array in a second step.
Or, you could wrap this procedure into a reusable function...
User avatar
mslonik
Posts: 144
Joined: 21 Feb 2019, 04:38
Location: Poland
Contact:

Re: Syntax issue, associative array with string key and command

11 Apr 2021, 03:43

Thank you for pointing out your remarks and suggestions.

I couldn't find anything about "regular" OutputVar in documentation or, opposite to that, about not implementing Objects, so I decided to open the separate topic dedicated to this issue in "Suggestions on documentation improvements" subforum. I link that new topic here.

Kind regards, mlsonik

My scripts on this forum: Hotstrings Diacritic O T A G L E
Please become my patreon: Patreon👍
Written in AutoHotkey text replacement tool: Hotstrings.technology
Courses on AutoHotkey :ugeek:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Bobak, mapcarter and 293 guests