System information
Manual:Scripting
28
Opearator Description Example
“!” , “not” logical NOT :put (!true);
“&&” , “and” logical AND :put (true&&true)
“||” , “or” logical OR :put (true||false);
“in” :put (1.1.1.1/32 in 1.0.0.0/8);
Bitwise Operators
Bitwise operators are working on number and ip address data types.
Opearator Description Example
“~” bit inversion :put
(~0.0.0.0)
“|” bitwise OR. Performs logical OR operation on each pair of corresponding bits. In each pair the result is “1” if one
of bits or both bits are “1”, otherwise the result is “0”.
“^” bitwise XOR. The same as OR, but the result in each position is “1” if two bits are not equal, and “0” if bits are
equal.
“&” bitwise AND. In each pair the result is “1” if first and second bit is “1”. Otherwise the result is “0”.
“<<” left shift by given amount of bits
“>>” right shift by given amount of bits
Concatenation Operators
Opearator Description Example
“.” concatenates two strings :put (“concatenate” . “ “ . “string”);
“,” concatenates two arrays or adds element to array :put ({1;2;3} , 5 );
It is possible to add variable values to strings without concatenation operator:
:global myVar "world";
:put ("Hello " . $myVar);
# next line does the same as above
:put "Hello $myVar";
By using $[] and $() in string it is possible to add expressions inside strings:
:local a 5;
:local b 6;
:put " 5x6 = $($a * $b)";
:put " We have $[ :len [/ip route find] ] routes";