Hi,
I am programming a script that collects some values from the wireless interface periodically (every 1s during 60s) and stores them in local arrays (mean, max, min) defined in the script.
At the end of the script I copy the local arrays to global variables, making them avaiIable to other scripts, and the scheduler launches my script again.
I found that when doing
:set $global_array $local_array
The global_array becomes a pointer to the local _array, and therefore after the first run of the script, whenever I write on the local_array, the global_array is also updated.
That was annoying and I presumed that I could solve it by converting to string the local_array when I copied it to the global_array:
:set $global_str [:tostr ($local_array)]
The global_str is now static, as I wanted, but I am surprised to see that the local_var is kept after every run of the script, even if I initialise it at the beginning of the script.
Here is a code that reproduces the problem:
# beginning of script
:local $bbb {0;0};
:set ($bbb->1) (($bbb->1)+1);
:log info message="$bbb";
# end of script
If I run the code several times, $bbb becomes:
0;1
0;2
0;3
...
So, I conclude that the code [:local bbb {0;0}] does not initialize the array to 0;0 and moreover the arrays are not local, as they maintain their values in subsequent executions of the script.
I would be grateful to receive an explanation.
Thank you in advance.