if else not working in script but run in terminal

It’s been 5 days scratching my head this thing i have this short script that run perfectly in terminal but not in script

the problem is that the false value contain in the if statement in not process by the script.

i tried many variance all of them refuse the false statement, anyone have a clue?
:local met value=“2”;
:local R2WIFI value=([/ip route get [find distance=3] gateway]);
:local met value=([/ip route get [find distance=3] distance]);
:put $R2WIFI;
:if ($met !=“3”) do={put $met;/ip route disable [find comment=WIFI]} else={/ip route enable [find comment=WIFI];/ip route set gateway=$R2WIFI [find comment=WIFI]};

i also tried global for declaration
this one is not executing the else part, if i reverse the true part with a negative not working either

everything running in the terminal
please help

is it a bug???

if ([/ip route get [find distance=3] distance] =3 )

is always true if route with distance 3 exists.
Due to you check distance of route with distance 3 and compare to 3.
If no such route than “get” returns error “no such item” (due to “find” returns empty array, not nil, not false but always array) and script stoppped to run (i.e “else” not running but whole script stopped due to error…)
Question - what will you wish this script to do?

setting the gateway with local R2WIFI [[/ip route get [find distance=3] gateway]];
disabling the route with the route _commented WIF_I if no metric 3 is shown in route table

i know it’s not what i am doing right now with the else (it’s not working either)

i tried many combination

they are working in terminal but not in the script shell

1 find a metric 3
2 get the gateway associated with it
3 if metric3 = true enable and set a commented route with the gateway(2)
4 if metric3 = false disable the commented route

variant

:local met value=“2”;
:local R2WIFI [[/ip route get [find distance=3] gateway]];
:local R2WIFI2 [[/ip route get [find distance=2] gateway]];
:local met [[/ip route get [find distance=3] distance]];
:put $R2WIFI;
:if ( $met=3 ) do={ put $met;/ip route set gateway=$R2WIFI [find comment=WIFI];/ip route enable [find comment=WIFI] } else={ / ip route set gateway=$R2WIFI2 [find comment=WIFI] }

Hm… possibly I need some beer %)))
Due to it is not clear for me what to do %)
For example if we success in

1 find a metric 3

it automatically means that always true is

3 if metric3 = true

and always false is

4 if metric3 = false

?
Or you meant that if p.1 success do p.3 and if p.1 not success do p.4?

yes thats it i mean your last statement