System information
Manual:Scripting
24
Line joining
Two or more physical lines may be joined into logical lines using backslash character (\). A line ending in a
backslash cannot carry a comment. A backslash does not continue a comment. A backslash does not continue a token
except for string literals. A backslash is illegal elsewhere on a line outside a string literal.
:if ($a = true \
and $b=false) do={ :put “$a $b”; }
:if ($a = true \ # bad comment
and $b=false) do={ :put “$a $b”; }
# comment \
continued – invalid (syntax error)
Whitespace between tokens
Whitespace can be used to separate tokens. Whitespace is necessary between two tokens only if their concatenation
could be interpreted as a different token. Example:
{
:local a true; :local b false;
# whitespace is not required
:put (a&&b);
# whitespace is required
:put (a and b);
}
Whitespace are not allowed
• between '<parameter>='
•• between 'from=' 'to=' 'step=' 'in=' 'do=' 'else='
Example:
#incorrect:
:for i from = 1 to = 2 do = { :put $i }
#correct syntax:
:for i from=1 to=2 do={ :put $i }
:for i from= 1 to= 2 do={ :put $i }
#incorrect
/ip route add gateway = 3.3.3.3
#correct
/ip route add gateway=3.3.3.3