Example 2: Branching the Work flow
In previous example, the work flow is very straightforward: when event happens, execute an action. Now let's make it a little complex: branch the work flow and let user to decide which branch to go.
Just like what we did in previous example: add a button element into the plot, open behavior editor, define a behavior for the button, and add the "Element Clicked" event.
Click the "Add Flow Control" button in the toolbar and then choose the "User Decision Branching..." in the pop-up menu.
In the popup window, input the question that will prompt user: "Do you know my location?".
Select the "Yes" node in behavior editor and click the "Add Action" button to add a "Show Message" action.
Here we input a praising message: "Ok, you are genius!"
Select the "No" node, and click the "Add Action" button to add a "Show Message" action.
In the "Show Message" edit window, we click the button to insert two element properties to represent the current location of the button.
You will be asked to choose an element to provide the property, we choose Button_1.
Then in the property chooser window, we can find the property that represent the X coordinate of Button_1.
The inserted element property looks like this:
We can do the same thing for inserting another property that represent the Y coordinate of Button_1, and complete the message by adding a few words:
The final behavior for Button_1 should looks like:
Now you can run the simulation by clicking the button in the toolbar of main window. This example shows how the branching works and the ability to access the element property. You can view this online example to see the result, or download the plot file.
In this example we use the "User Decision Branching", which can branch the work flow according user's decision. ForeUI also support another two types of branching:
|•||Conditional Branching: do branching according to the conditions.|
|•||Switch Branching: do branching according to the value of expression.|
Please read the Branching section for more details.