string comparaition

hi,
please, I don’t really understand why this script is not working when making comparaison to switch on sim-slot, it’s seems mikrotik don’t compare string values !!! Please help ?

:local simlte [/system routerboard sim get value-name=sim-slot]
:if ($PingFailCountLTE >= $FailTreshold) do={
:if ($PingFailCountLTE >= 100) do={
:set PingFailCountLTE 100
}
:if ( $simlte != “b”){
/system routerboard sim set sim-slot=b;
/log warning " etat du port lte va changer à : $simlte"
delay 60s;
};
}
:if ($PingFailCountLTE < $FailTreshold) do={

:if ( $simlte != “a”){
/system routerboard sim set sim-slot=a;
/log warning " etat du port lte va changer à : $simlte"
delay 60s;
};
}

Hey,

RouterOS does support String comparison :wink:
There are few bugs in the script so maybe that is why it is not working.
Remember to put proper construction of :if statement. There are missing “do=” syntax. proper syntax is :if (sth) do={} else={}
delay command must be followed by “:” so :delay time_in_secs is proper syntax.
Once combining plain text with variable into 1 string put it inside brackets in the following manner: :log info ("test notification number: ".$variable);

I hope it will help a bit :wink:

You do not need semicolon at end of each line ; , only when multiple commands on same line.

Use this to see what type your variable is.

:put [:typeof $myStr]

It its not string, you can force it to string.

:if ([:tostr $myStr] = "something") do={:put "yes"}