Well, no 2-dimensional arrays - it is still bearable.
This is a big flaw in the scripting language of router OS. Due to the lack of support for dynamic variables (reffer to, or create a variable with name from the value of another variable) and the possibility to define array’s keys in the same manner, it is not possible to create beautiful, functional and short scripts (what is important - the size of the script is limited too).
What is strange - refer to the already created keys for the arrays with variable instead key (both numeric and string) is possible. And you even can change they values, but to create - it is impossible!
I can not imagine how programmers have written ROS scripts without “foreach key, val” (“key” added only recently)
I wrote in the question of support, whether it is planned in the near future to add the above-mentioned features. I hope the answer will be positive
Nowdays, the result can be obtained such method for example:
:global GlobalScriptBuffer;
:local x ({});
:local key "key_name";
:local val "value";
:local temp [:parse (":global GlobalScriptBuffer {\"".$key."\"=\"".$val."\"}")];
$temp;
:set x ($x , $GlobalScriptBuffer);
:put ($x->$key);
#Returns "value"
It’s quite cumbersome, plus you need to keep an eye is to no other concurrently running script (or a copy of this) has not change a value in a global variable GlobalScriptBuffer - sometimes it’s critical and dangerous.
So waiting for positive changes in parcer. I could be wrong, but it seems to change can be even backwards compatible …
About what speech. A lot of code for setting the scripts in queue. A lot of code for simple operations. All this may be avoided by adding dynamic variables and posibility to define arrays key from variable’s values.
So waiting for action from the developers, and continue to torment our brains
This method works in this simple scenario, but as strings are pointers they won’t works in complex cases, it took me hours to figure this out. Maybe this works with int variable i haven’t tested it thoroughly.