! Variables in firewall filters

I have

:global eruWAN ether1
/ip firewall filter add chain=forward out-interface=!($eruWAN) …

which the CLI doesn’t like. Nor
/ip firewall filter add chain=forward out-interface=!$eruWAN …

/ip firewall filter add chain=forward out-interface=(!$eruWAN) returns “Script Error: cannot logically negate string” which makes sense, but

/ip firewall filter add chain=forward out-interface=!ether1 … works.

How can I use the variable $eruWAN there?

In cli wrap the code i brackets. {code}

{
:global eruWAN ether1
/ip firewall filter add chain=forward out-interface=!($eruWAN) ....
}

As error says you cannot logically negate string.
by specifying !“string” you are trying to perform logic operation on string and then apply it as a value.
To pass ! as part of the value you should pass it as a part of string “!$your_var”

[admin@MikroTik] /ip/firewall/filter> add out-interface="!$x" chain=xx         
[admin@MikroTik] /ip/firewall/filter> print 
Flags: X - disabled, I - invalid; D - dynamic 
 0    chain=xx out-interface=!ether1

do not matter, if you use GLOBAL, instead of local.

sorry.. missing

:global x "ether1"



[admin@MikroTik] /ip/firewall/filter> :global x "ether1"
[admin@MikroTik] /ip/firewall/filter> add out-interface="!$x" chain=xx         
[admin@MikroTik] /ip/firewall/filter> print 
Flags: X - disabled, I - invalid; D - dynamic 
 0    chain=xx out-interface=!ether1