Referencing value in array of variables

Hello, I have the following code example:

:local $array { "item1"="value1"
		"item2"="value2"
		"item3"="value3"
		}

I would like to reference, say, “value2” specifically as a single value in a specifically created new variable.

So I would end up with “newVariable” specifically outputting only “value2”

I tried $array->1->1 but that doesn’t seem to work, can anyone point me in the right direction?

Thank you.

The code example do not work at all,
first, you can not directly declare one variable with $ on name
second, this is not one array, missing all ; between items.

the correct code, regardless the final purpose, is

:local array { "item1"="value1"; "item2"="value2"; "item3"="value3" }

and the correct way to recall value is, for example:

:local newVariable ($array->"item1")

Thanks, sorry, you’re right, that’s not actually what I have in the script, let me enter it exactly:

:local array { "item1"="value1"; \
	       "item2"="value2"; \
	       "item3"="value3"; 
	     }

However, both of the array elements (item and value) are customizable, so I wanted to find a way where I could reference the “first” element’s “value” as both “item” and “value” are unknown to me before anyone changes the items in their own implementation (i.e. position 0,1) hence me trying something like ->0->1

Would there be any way to reference the values if both item and value are unknown? I’d also like to be able to reference “item1” and “value1” separately for different purposes.

Working concept:

{
    :local array { "item1"="value1"; "item2"="value2"; "item3"="value3" }
    :foreach x,y in=$array do={
        :put "$x=$y"
    }
}

It’s morning here, you’ll have to forgive me :stuck_out_tongue: edited to update.

Is there any way of doing it without a for loop? Surely there must be some way to reference a single value without iterating over the entire loop

No, the index/label must be know for retrieve the variable name

for retrieve the value, for example the first, you can use

:put [:pick $array 0]

but you do not have the variable name, but only the value.