How to AND :IF sentences

Hi Guys,

I know the following code is wrong, but is there away to AND 2 or more :IF sentences in order to take an action such as route setting ?

Here is teh wrong code:

:if ([/tool netwatch get R1 status]=up) &&
:if ([/tool netwatch get R2 status]=up)
/ip route set [/ip route find comment=fail-over-route] gateway=(R1)

any idea on how to rewrite this to be acceptable ?

Many thanks

Try this:

:local R1S [/tool netwatch get [/tool netwatch find host=$R1] status]
:local R2S [/tool netwatch get [/tool netwatch find host=$R2] status]
:if ($R1S = up && $R2S = up) do={
     /ip route set [/ip route find comment=fail-over-route] gateway=$R1
}

–Eric

Thank you Eric for the answer. Altough the post was old, I was still in great need of that script.