Transfer contents of local array to global array with variable name

Hello everyone!
Can you help me with this problem. I want to transfer the contents of a local array to a global array with variable name. The script below is not working.

:local counter 1;
:local arrayname “array$counter”;
:local contents {key1=value1;key2=value2;key3=value3};
[:parse “:global $arrayname $contents”]

When I run the script, there is no global array named “array1” in Environment. There might be solution for this but I can’t figure it out.
Thanks for your help.

Full of errors, is logic that do not work.

But also if corrected,

:local counter  1
:local arrName  "array$counter"
:local arrValue {"key1"="value1";"key2"="value2";"key3"="value3"}

:put ":global $arrName $arrValue"

do not put anything because arrValue is one array, and you can not use it on script text that “parse” must interpret.


On this way still not produce something usable:

{
:local counter  1
:local arrName  "array$counter"
:local arrValue {"key1"="value1";"key2"="value2";"key3"="value3"}
:put ":global $arrName {$[:tostr $arrValue]}"
}

Because
:global array1 {key1=value1;key2=value2;key3=value3}
is invalid: missing quotes!!!


How solve rapidly without creating a function that create correct text for array, etc.?
Just create temporary global var, for set value later…

{
:local counter  1
:local arrName  "array$counter"
:local arrValue {"key1"="value1";"key2"="value2";"key3"="value3"}
:global temp123123 $arrValue
[:parse ":global temp123123 ; :global $arrName \$temp123123"]
}