Basic script fails

:log info “Start”
:global gip1
:set gip1 “0.0.0.0”
:log info “End”

if the variable has a previous value, for example, 10.0.0.5, then the global variable gip1 is destroyed, it can not be displayed in the environment tab under winbox, or printed from the telnet console (even the RouterOS becomes unstable sometimes).

RouterOS 5.24, RB2011UAS

:global gip1 “0.0.0.0”

That will overwrite it also.

I think you want this.
:global gip1

:if ([:typeof gip1] = “nothing”) do={:set gip1 “0.0.0.0”}FYI in 6.2 it is “nil” since it is a global, but it is “nothing” <= 6.1 and >= 6.3.

-Eric

Thanks

The problem is just that the ‘set’ command destroy the variable completely, and the router becomes unstable when latest value of variable is not “0.0.0.0”. So, this code don’t solve the issue :frowning:

I reported the problem to Mikrotik. My RB2011 probably is wrong … becaus it is no sense. Is a very simple code…