Programming Guide |
Conditionally executes one or more JPL statements
iflogicalExpr
[else if
statementBlocklogicalExpr
statementBlock
]
...
[elsestatementBlock
]
logicalExpr
- Specifies the condition under which JPL executes
statementBlock
, wherelogicalExpr
can be any logical expression. For more information on logical expression construction, refer to "Logical Expressions" in Application Development Guide.statementBlock
- One or more statements that JPL executes if the preceding
logicalExpr
evaluates to true. IfstatementBlock
has more than one statement, enclose the block with open and close blocking characters{}
on the lines before and after.else if
logicalExpr
- Optionally specifies the statement block to execute if all previous
if
andelse if
conditions evaluate to false andlogicalExpr
evaluates to true.else
- Optionally specifies the statement block to execute if all previous
if
andelse if
conditions evaluate to false. Eachelse
must be paired with anif
statement and follow allelse if
statements associated with thatif
.
The
if
command specifies conditional execution of other JPL statements. Eachif
can be followed by one or moreelse if
commands to create a chain of conditional processing. JPL executes eachif
andelse if
in the chain until it evaluates one of the conditions to true; JPL then executes the statement block and exits the chain. If all conditions in anif
chain evaluate to false and the chain ends with anelse
command, JPL executes theelse
statement block. If theif
chain omits anelse
command, JPL simply exits the chain and continues module execution.
//Determine a person's sex, based on personal title.
if title == 'MR'
sex = 'Male'else if title == 'MS'
sex = 'Female'else if title == 'MRS'
sex = 'Female'else if title == 'MISS'
sex = 'Female'else
{
sex = 'Unknown'
msg err_reset 'Please supply a title.'
}