![]() | Programming Guide | ![]() |
Conditionally executes one or more JPL statements
iflogicalExpr[else if
statementBlocklogicalExprstatementBlock]
...
[elsestatementBlock]
logicalExpr- Specifies the condition under which JPL executes
statementBlock, wherelogicalExprcan 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
logicalExprevaluates to true. IfstatementBlockhas more than one statement, enclose the block with open and close blocking characters{}on the lines before and after.else iflogicalExpr- Optionally specifies the statement block to execute if all previous
ifandelse ifconditions evaluate to false andlogicalExprevaluates to true.else- Optionally specifies the statement block to execute if all previous
ifandelse ifconditions evaluate to false. Eachelsemust be paired with anifstatement and follow allelse ifstatements associated with thatif.
The
ifcommand specifies conditional execution of other JPL statements. Eachifcan be followed by one or moreelse ifcommands to create a chain of conditional processing. JPL executes eachifandelse ifin 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 anifchain evaluate to false and the chain ends with anelsecommand, JPL executes theelsestatement block. If theifchain omits anelsecommand, 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.'
}
![]()
![]()
![]()
![]()