There are two forms of loop action usages:

  • A while loop action usage performs a body clause action usage iteratively, as long as its while expression continues to evaluate to true and its until expression continues to evaluate to false.
  • A for loop action usage performs a body clause action usage iteratively, assigning a loop variable successively for each iteration to the values resulting from the evaluation of a sequence expression.

Specifying while loop actions for actions

Specifying while loop actions for actions via the Textual Editor

To specify while loop actions for actions via the Textual Editor


  1. In the Textual Editor, place the cursor where you want to create the while loop action and do one of the following:

    1. For an unnamed while loop action usage, declare the keyword while.
    2. For a named while loop action usage, declare the keyword action, specify the element name, and then the keyword while.

      You can also use keywords loop or while true (interchangeably) and omit the while expression, allowing the action to loop until the until expression evaluates to true.

  2. (Optional) Follow with the expression for the while action usage.
  3. Specify the body clause by doing one of the following:
    1. For an unnamed body clause, follow with the body for the body clause.
    2. For a named body clause, declare the keyword action, specify the clause name, and follow with the body for the body clause.
  4. (Optional) Specify the until keyword followed by a boolean-valued until expression. 
  5. Click the Synchronize button.

// ---------- while loop action usage 

action batteryMonitor {

    // unnamed while loop action usage with a while expression 'battery < 100' and an unnamed body clause:
   
while battery < 100 {
    // named 'batteryCheck' while loop action usage with a while expression 'battery < 100' and a named body clause 'action chargeBattery':
    action batteryCheck while battery < 100 action chargeBattery {

        action AddCharge;
    } until charge >= 100;
}

// ---------- keywords 'loop' and 'while true' are equivalent and can be used interchangeably

action batteryMonitor {

    // unnamed while loop action usage without a while expression and an unnamed body clause:
   
loop {
    // named 'batteryCharge' while loop action usage without a while expression, with a named body clause 'action chargeBattery':
    action batteryCharge loop action chargeBattery {
    // unnamed while loop action usage with a while expression 'true' and an unnamed body clause:

    while true {
    // named 'batteryCharge' while loop action usage with a while expression 'true' and a named body clause 'action chargeBattery':

    action batteryCharge while true action chargeBattery {

        action AddCharge;
    } until charge >= 100;
}

Specifying while loop actions for actions via the view palette

To specify while loop actions for actions via the view palette


  1. In the view palette, under the Other Actions group, click the while button to create a while loop action usage element.
  2. Click on an action symbol in the view pane where you want to create the while loop symbol.
  3. (Optional) Specify the element via the Textual Editor.

Specifying for loop actions for actions

For a for loop action usage, the action declaration part is followed by the keyword for, which introduces a loop variable declaration followed by the keyword in and a sequence expression, and, after that, a body clause. 

Specifying for loop actions for actions via the Textual Editor

To specify for loop actions for actions via the Textual Editor


  1. In the Textual Editor, place the cursor where you want to create the for loop action and do one of the following:

    1. For an unnamed for loop action usage, declare the keyword for.
    2. For a named for loop action usage, declare the keyword action, specify the element name, and then the keyword for.
  2. Follow with the loop variable declaration for the for action usage.
  3. Specify the keyword in and the sequence expression.
  4. Specify the body clause by doing one of the following:
    1. For an unnamed body clause, follow with the body for the body clause.
    2. For a named body clause, declare the keyword action, specify the clause name, and follow with the body for the body clause.
  5. Click the Synchronize button.

action updatePosition {

    // unnamed for loop action usage with a loop variable declaration 'power', sequence expression 'powerProfile' and an unnamed body clause:
    for power in powerProfile {
    // named 'dynamicScenario' for loop action usage with a loop variable declaration 'power', sequence expression 'powerProfile' and a named 'dynamicsStep' body clause:
    action dynamicScenario for power in powerProfile action dynamicsStep {
        assign position := ComputeDynamics(position, power);
    }
}

Specifying for loop actions for actions via the view palette

To specify for loop actions for actions via the view palette


  1. In the view palette, under the Other Actions group, click the for button to create a for loop action usage element.
  2. Click on an action symbol in the view pane where you want to create the for loop symbol.
  3. (Optional) Specify the element via the Textual Editor.