if

Allows you to use the IF, ELSE, ELSEIF, and END commands to execute a group of commands conditionally. The execution of commands bracketed by IF and END depends on the value of an expression.
You can use the IF command with or without the ELSE command.

Format:

 
if
if condition =
(expression)
end
 
if condition =
(expression)
else
 
end
 

Example:

 
if condition=(db_exists ("mar1"))
marker modify marker= mar1 location=2,0,0
else
marker create marker=mar1 location=2,0,0
end
 
In the above example, if the marker MAR1 exists, Adams View modifies its location. If the marker does not exist, Adams View creates it and sets its location.

Description:

 
Parameter
Value Type
Description
Condition
Expression
If the expression evaluates to a non-zero value, Adams View executes the commands following the IF or ELSEIF command up to the ELSE, when present, or the END, if you do not use the ELSE. If the expression evaluates to zero and you used ELSE, Adams View executes the commands between the ELSE and the END commands.

Extended Definition:

1. The question-mark/colon (?:) operator, used in a conditional expression, replaces an IF/ELSE command that distinguishes one of two values. The expression consists of three parts: a condition whose truth determines which value is selected, and two expressions for the values.
condition expression ? expression a : expression b
When evaluated, the conditional operator takes on one of the two values. The expression that comes before the question-mark is interpreted as boolean-valued. If it is true (non-zero), then expression a is used as the value of the conditional operator, otherwise expression b is used as the value.
For example, consider the commands below:
if condition = (variable_a < variable_b)
variable set variable = variable_min real = (EVAL(variable_a))
else
variable set variable = variable_min real = (EVAL(variable_b))
end
This can be expressed more concisely by using a ?: conditional operator:
variable set variable = variable_min &
real = (EVAL((variable_a < variable_b)? variable_a : variable_b))

Tips:

1. You can have any number of ELSEIF CONDITION commands.