system script error, console OK

I am running some tests, however I am puzzled by this problem. I try to get a message about the variables collected previously, but it only shows a blank message. But when I run it through the terminal I have no problem. For what is this?

:if ( [/ping 192.168.5.54 size=28 interval=30ms count=1 ] = 0 ) do={[:global xc 20]} else={:global xc 50} ;
log warning $xc

Your variable is declared too late. It is valid inside the blocks only. Try this:

:global xc;
:if ([ /ping 192.168.5.54 size=28 interval=30ms count=1 ] = 0) do={
  :set xc 20;
} else={
  :set xc 50;
}
:log warning $xc;