# Standard simple if
if {some condition} {
# Note that the open-brace for the body is on the same line
# as the if-command and condition.
some conditionally executed script...
}
# Standard simple if with else clause
if {some condition} {
some conditionally executed script.
} else {
some script to execute if the condition is not satisfied.
}
# Standard multi-test if
if {first condition} {
thing to do if the first condition succeeds
} elseif {second condition} {
thing to do if the first fails, but the second condition succeeds
} else {
what to do if none of the conditions match - this one is optional,
but typically good practice to anticipate unexpected responses
}
# Handling complex (i.e. long) conditions
if {
this condition stretches over
multiple lines
} then {
thing to do if the condition succeeds
}
转载于:https://blog.51cto.com/freedomm/1844596