Global Variable problem in 6.x

I am using a script for monitoring and alerting UPS state,

After upgrade to 6.3 the script stops working correctly and I have suspiction, that it did not defines global variables well.

#declaration
:global flagonbatt
:local curonbatt

\

First run? If so, we need to initialize the global flags

:if (("-" . $flagonbatt)="-") do={:set flagonbatt 0}
:if (("-" . $flagbattlow)="-") do={:set flagbattlow 0}

/system ups monitor [/system ups find name="ups1"] once do={:set curonbatt $"on-battery";}

:if (($curonbatt) && ($flagonbatt=0)) do={
:set flagonbatt 1
:log info ("Power-Fail: .........)
}

:if ((!$curonbatt) && ($flagonbatt=1)) do={
:set flagonbatt 0
:log info ("Power-Restore: .........)
}


After running the script I don't see flagonbatt variable in /system script environment. On older ROuterOS versions (4.16), this works OK.

I have searched for any difference in scripting in v 6.x, but I did not found anything helpful.

Do anybody have any idea what is wrong there ?

Thanks.

Jiri

Solved.

The problem was, that script did not have set “policy” policy. After setting this policy, global variables are initialised and also visible in /system scripts environment.

I don’t know if it is intended or a bug.

Maybe this information will be useful for anybody else.

I HAVE TO CONFIRM TAH BUG!!!
When there is no “policy” set at the script “Policy” settings - the GLOBAL variable - DON"T WORK. I mean that script does not set defined global variable by : global. You have to set “policy” at Policy setting in script to have it working.
PLEASE REPAIR THAT BUG!

Yes, I confirming too.
There have to be checked “policy” Policy to have :global variable working.
Anyone else?