OK,
I found the way
. The part I was missing was - when doing :set ($array->$key) $value - the $key needs to be string, cannot be integer. So now the proper example is as follows:
### Initiating the array
:local xxx {1="1st value";2="2nd value";3="3rd value";n="nth value"}
###Getting all values (with the keys) from the array
:foreach key,value in=$xxx do={
:put "Table entry number $key has the value: $value"
}
###Changing the existing value in the array
:put "Changing 3rd variable"
:set ($xxx->"3") "Different 3rd value :)"
###Reading the specific variable
:local var3 ($xxx->"3")
:put "Variable 3 is: $var3"
###Adding a new value
:put "Adding 5th variable"
:set ($xxx->"5") "5th value"
###When adding the value with a script, we need to make sure the array "key" is string, not integer, so - for example:
:for n from=15 to=19 do={
:local number [:tostr $n]
:put "Setting value $n"
:set ($xxx->$number) "$n-th value"
}
###The result is as it should be :D
:local varsize [:len $xxx]
:put "The array now has $varsize elements:"
:foreach key,value in=$xxx do={
:put "Table entry number $key has the value: $value"
}