beta5: Is this an error in the script parser?

Hi, can please a RouterOS developer check this posting:
http://forum.mikrotik.com/t/how-to-auto-start-a-script-at-interface-link-up-down/139637/18
It looks like a parser error.

The intention is to initialize the global variable “gArr” in the script only if it does not already exist.
This part works ok, but the latter “:put $gArr” does not output it, ie. the output is empty.
I suspect an internal parser error regarding scope visibility…

First you are trying to use undeclared variable gArr
Then you are declaring global variable with the same name in ‘if’ scope.

I assume that you want to access already existing global variable and if it does not exist or is empty then add first entry, in that case script should look something like this:

{
  # declare variable that you are trying to access
  :global gArr;
   :if ([:typeof $gArr] = "nothing" or [:tobool [:len $gArr]] = false) do={
      # make changes to gArr
      :set $gArr { key1="val1"}
   }
   :put $gArr
}

@mrz, thank you very much for this solution. Indeed, that’s exactly what was intended.