Using Control ActionsSetup and Operation of Branch, If, Loop, Break, and Return ActionsTango application files can contain control actions that control the execution of other actions in the file. This chapter covers the setup and operation of the following actions.
![]() Jumping to a Designated Action (Branch Action)The Branch action causes a jump to a designated action or to an action group. You can set the Branch action to jump to a different action in the same file the Branch action is in or an action in another file. There are restrictions on what position and kinds of action a Branch action can jump to. Branch Action Destination RulesBranch actions have the following rules for valid destinations:
The preceding rules mean that Branch actions cannot branch to an action that they dominate or that a sister action dominates. For example, look at this application file: ![]() |
|
Examples of valid branches are: The actions are in the same action block and at the same level. Action7 is at the outermost level. Those actions are immediate parents of Action3. Action2 is the first-level child of an immediate parent of Action3, If_1. Examples of invalid branches are: They are not in the correct relationship: Action4 is downward from Action1. They are not in the correct relationship: Action6 is downward from Action2. Even though ElseIf3 is the first child of a immediately dominating parent action (If_1), this branch is not allowed because branching to an Else If action is invalid. Branching to Other Application Files When Caching
|
|
![]() |
When you drag the Branch action icon from the Actions bar into an
application file, the Branch action editing window appears.
To set up a Branch action
Executing a Branch ActionWhen Tango Server executes a Branch action, it jumps to the designated action. If the Return to next action after branch option is selected, Tango returns to the action following the Branch action when a Return action is encountered. ![]() Conditional Action Execution (If Action)The If action evaluates an expression and based on the result of that expression affects the control flow of the file. The If action also has two related actions called Else If and Else. The If action can exist with or without one or more Else If actions and with or without a single Else action. The general forms of these actions are as follows:
|
Setting Up an If Action |
|
![]() |
When you drag the If or Else If action icon from the Actions bar
into an application file, the If action editing window appears.
By default, the If action editing window appears in its basic view, allowing you to create expressions quickly. An expression line appears in the dialog box, ready for you to edit.
|
An advanced view is also available that gives you more flexibility than the basic view when specifying evaluation expressions. You change the type of If action by selecting If, Else If, or Else from the Action drop-down list. The If and Else If action editing windows are basically the same, and you enter evaluation expressions the same way for both of them. When you select Else, however, only the Action drop-down list is active. This allows you to change to another If action type.
Basic ViewTo specify values for the basic view parameters |
|
|
|
For more information about inserting meta tags in entry fields, see "Inserting Meta Tags". |
You can also use the Insert Meta Tag command to enter many of the commonly used meta tags. To insert a meta tag, either click the field and choose Insert Meta Tag from the Edit menu, or right click the field and choose Insert Meta Tagz` from the context-sensitive menu that appears. To add a new parameter row |
Advanced ViewWhen you click Advanced in the basic view, the following happens:
The advanced view presents a free-form text area to give you more flexibility than the basic view when specifying evaluation expressions. For example, if you want to use parentheses to control the evaluation order, you can enter the expression in this area. |
|
For more information, see "<@CALC>" in the Meta Tags and Configuration Variables manual. |
The expression entered here takes the same form as expressions specified for the <@CALC> meta tag. If the expression evaluates to "1" or "true", the expression is considered to be true; otherwise, it is considered to be false. You can automatically regenerate an expression appearing in the basic view in the advanced view as follows:
To return to the basic view, click Basic.
Performing Operations on If ActionsWorking with If actions is similar to working with grouped actions. For information on the operations you can perform on groups, see "Working With Action Groups" . Executing an If ActionIf Tango Server evaluates the expression to true, action processing continues with the list of indented actions. If the expression evaluates to false, action processing jumps to the first action after the list of indented actions, which could be an Else or Else If action. If that action is an Else If action, Tango Server evaluates the Else If expression to determine whether it should execute the indented actions under the Else If action. If the action is an Else action, then Tango Server executes the actions indented under the Else action. Once processing of the indented actions is complete, processing continues with the next non Else If or Else action at the same level as the If action.
![]() Repeating Actions (Loop Actions)Loop actions repeat the execution of a set of contained actions for a given number of times or while an expression evaluates to true.
|
Tango also includes a Break action you can use to exit a Loop action before the loop conditions for termination are met. |
|
There are two kinds of Loop actions: While Loops and For Loops. Setting Up Loop ActionsWhile Loop |
|
![]() |
A While Loop action executes the actions in the loop while an expression evaluates to true. When you drag the While Loop action icon from the Actions bar into an application file, the While Loop action editing window appears in its basic view, allowing you to create evaluation expressions quickly. If the expression you specify does not evaluate to true when Tango first executes the While Loop action, the enclosed actions are never executed.
|
The basic view for a While Loop action is similar to the basic view for If and Else If actions. |
|
The While Loop action editing window also has an advanced view that gives you more flexibility than the basic view when constructing evaluation expressions. For example, you can use parentheses to control the evaluation order. |
|
This view is similar to the advanced view for If and Else If actions. For LoopThe other loop action is the For Loop action, which repeats a set of contained actions for a given number of times. When you drag the For Loop action icon from the Actions bar into an application file, the For Loop action editing window appears |
|
![]() |
.
Set the parameters in a For Loop action as follows:
Performing Operations on Loop ActionsWorking with Loop actions is similar to working with grouped actions. For information on the operations you can perform on grouped actions, see "Working With Action Groups" . Executing Loop ActionsWhile LoopTango Server evaluates the expression before executing the contained actions. If the expression evaluates to true then the contained actions are executed. Then, Tango returns to the While Loop action and re-evaluates the expression. If it is true, the contained actions are executed again. This process continues until the expression evaluates to false. Execution then continues at the next action outside the loop. If Tango Server finds the expression is invalid, it returns a runtime error. Tango Server evaluates any meta tags in the expression on each pass through the loop. For LoopIf Start Value is a meta tag, Tango Server evaluates it prior to the first pass through the loop. If the To and Increment/Decrement By fields contain meta tags, Tango Server evaluates them on each pass through the loop. At the end of the loop, execution returns to the top. This process continues until the loop counter exceeds the value specified in the To field. Execution then continues with the next action outside the loop. ![]() Exiting a Loop (Break Action)The Break action prematurely terminates processing in a loop or group action. On termination, processing continues at the next action after the loop or group. |
![]() |
Drag the Break action icon from the Actions bar into a Loop or
Group action at the point you want the loop or group to terminate.
On execution, the Break action terminates the loop, and processing continues at the next action after the loop.
![]() Ending File Processing (Return Action) |
![]() |
The Return action ends application file processing and returns any accumulated Results HTML to the Web browser. |
For more information, see "Jumping to a Designated Action (Branch Action)". |
The exception to this is if the current execution flow is the result of a Branch that had its Return to next action after branch option set. In this case, the execution returns to the action following the Branch when a Return action is encountered. |
Copyright © 1998, Pervasive Software Inc. All rights reserved.