If action
An if action usage evaluates a condition expression and then performs a then clause action usage if the expression evaluates to true, or, optionally, an else clause action usage if the expression evaluates to false.
Specifying if actions for actions
Specifying if actions for actions via the Textual Editor
To specify if actions for actions via the Textual Editor
In the Textual Editor, place the cursor where you want to create the if action.
Specify the if action usage:
Do one of the following:
- For an unnamed if action usage, declare the keyword if.
- For a named if action usage, declare the keyword action, specify the element name, and then the keyword if.
- Follow with the condition expression for the if action usage.
- Specify a then clause by doing one of the following:
- For an unnamed then clause, follow with the body for the then clause.
- For a named then clause, declare the keyword action, specify the element name, and follow with the body for the then clause.
- (Optional) Specify the else if clause action usage:
- Do one of the following:
- For an unnamed else if action usage, declare the keyword else if.
- For a named else if action usage, declare the keyword else, then the keyword action, specify the element name, and then the keyword if.
- Follow with the condition expression for the if action usage.
- Specify a then clause by doing one of the following:
- For an unnamed then clause, follow with the body for the then clause.
- For a named then clause, declare the keyword action, specify the element name, and follow with the body for the then clause.
- Do one of the following:
- (Optional) Specify the else clause action usage:
- Do one of the following:
- For an unnamed else action usage, declare the keyword else.
- For a named else action usage, declare the keyword else, then the keyword action, and specify the element name.
- Specify the body for the else clause.
- Do one of the following:
- Click the Synchronize button.
// unnamed if, then clause, and else clause action usages:
action testAlarm {
if threat.level == high { // unnamed if action usage followed by the if condition expression and an unnamed then clause action usage
perform soundAlarm {in cause = threat;} // body of the then clause action usage
} else if threat.level == medium { // unnamed else clause action usage which is itself an if action usage, followed by the if condition expression and an unnamed then clause action usage
action sendNotification {in msg = threat;} // body of the else if action usage
} else { // unnamed else clause action usage
action beginMonitoring {in target = threat;} // body of the else action usage
}
}
// named if, then clause, and else clause action usages:
action testAlarm {
action threatHigh if threat.level == high action alarm { // named 'threatHigh' if action usage followed by the if condition expression and a named 'alarm' then clause action usage
perform soundAlarm {in cause = threat;} // body of the 'alarm' then clause action usage
} else action threatMedium if threat.level == medium action notify { // named 'sendNotification' else clause action usage which is itself an if action usage, followed by the if condition expression and a named 'notify' then clause action usage
action sendNotification {in msg = threat;} // body of the 'sendNotification' else if action usage
} else action monitor { // named 'monitor' else clause action usage
action beginMonitoring {in target = threat;} // body of the 'monitor' else action usage
}
}
Specifying if actions for actions via the view palette
To specify if actions for actions via the view palette
- In the view palette, under the Other Actions group, click the if button to create an if action usage element.
- Click on an action symbol in the view pane where you want to create the if symbol.
- (Optional) Specify the element via the Textual Editor.