It is necessary to create a named three-dimensional array. I’ve been stomping the third day, I can’t find a mistake.
the name of the keys is not known in advance; therefore, they must be added in the process.
An example that works:
:local key1 "D04DEA1091709160632421214";
:local key2 "D04DEA34224EB3D99170915112732146";
:local key3 3;
:local key4 4;
:local val1 "MyValue1";
:local val2 "MyValue2";
:local a ({});
:set ($a->$key1) ({});
:set ($a->$key2) ({});
:set ($a->$key1->$key3) $val1;
:set ($a->$key2->$key4) $val2;
:log info $a;
:log info [:len $a];
result:
D04DEA1091709160632421214=;;;MyValue1;D04DEA34224EB3D99170915112732146=;;;;MyValue2
2
As you can see from the example, two rows are created, the first fits the value in the third column, the second fits the value in the fourth column.
OK, I transfer this construct to my code, but it stops working as it should.
I will not show all the code because of the size, but I will try to convey the problem:
:global struct;
:local ss ({});
for it from=0 to=([:len $struct] - 1) do={
:if ($struct->$it->"udhi") do={
:local concatenatedName (($struct->$it->"oaLine").($struct->$it->"sctsLine").($struct->$it->"udhOctet1"));
:local concatenatedNum ($struct->$it->"udhOctet3");
:log info $concatenatedName;
:log info $concatenatedNum;
:if ([:typeof ($ss->$concatenatedName)] = "nothing") do={:set ($ss->$concatenatedName) ({});};
:set ($ss->$concatenatedName->$concatenatedNum) $concatenatedNum;
}}
:local l [:len $ss];
:local t [:typeof $ss];
:log info "len ss: $l";
:log info "type ss: $t";
:log info $ss;
:set ($ss->"D04DEA1091709160632421214"->7) "test";
:log info $ss;
result:
1
D04DEA1091709160632421214
4
D04DEA34224EB3D99170915112732146
2
D04DEA1091709160632421214
1
D04DEA1091709160632421214
3
D04DEA1091709160632421214
2
D04DEA34224EB3D99170915112732146
3
len ss: 2
type ss: array
D04DEA1091709160632421214=;1;2;3;4;D04DEA34224EB3D99170915112732146=;1;2;3;4
D04DEA1091709160632421214=;1;2;3;4;;;test;D04DEA34224EB3D99170915112732146=;1;2;3;4;;;test
Accordingly, it can be seen that both keys refer to the same value address. Although the first example works as it should. Where am I wrong?