The if Statement
if <condition> {
[ statements ]
}
The if
statement evaluates a condition. When the
<condition> evaluates to true
, the statements within the subsection
are executed. When the <condition> evaluates to false
, those
statements are skipped.
if (&User-Name == "bob") {
reject
}
Practical Suggestions
There are a number of practical suggestions which make it easier to work with conditions.
Brackets are usually optional.
There is no need to put brackets around a <condition>. The following two examples work identically:
if (&User-Name == "bob") {
reject
}
And without:
if &User-Name == "bob" {
reject
}
The same behavior applies to conditions with complex statements using
&&
and ||
. So long as the text between the if
and the {
is a
valid condition, it will be parsed correctly.
Multi-line conditions
A <condition> can span multiple lines. There is no need to use \\
at the end of a line. The following condition is valid:
if (&User-Name ==
"bob") {
reject
}
Actions
The last entry in an if
section can also be an actions subsection.