Before reading this section, we highly recommend reading both Getting started with conditions and Conditions.
Whenever you add a condition to an action in the Studio, such as a formula, you can read it as “if the condition is satisfied, do this”.
An everyday example may be something like “If it rains outside, I will have to put on my coat”.
This condition is structured with a condition-part and a statement-part.
The part “if it rains outside” is the condition, “I will have to put on my coat” is the statement.
So, the general structure is: if
However, in reality you may encounter more complex structures. The Studio has else-conditions and condition blocks to help you with these.
An else-condition is an extension to the normal
if-then structure of a condition.
For example, consider the following: “If I have less than €100, I eat at home; if I have more I will go to a restaurant if it’s Saterday”
In the Berkeley Studio, you might come up with this structure:
However, now you have to check for ‘money’ twice!
In the Studio you can solve this with an
This is done in the following way:
Note that the check box for an else-condition will only appear whenever your previous action has a condition!
This is due to the structure of and
if-else-then: there can only be an
else if there’s also an
Now, our variable
eat will be ‘restaurant’ only if
money is not lower than 100 and if the day is Saterday.
Another example could be the activity of someone: if it’s raining, he will stay inside. If it’s not and the temperature is higher than 20 degrees, he will play football.
You can also have multiple actions that you want to do that all depend on a single condition. For example, imagine your employer has rules for people over 40 years old. They have to work a bit more each day, but they get more salary and more holidays. In the Berkeley Studio, you might model this situation this way:
However, now you have to enter the condition for each and every action.
Furthermore, you might want to add extra condition, such as checking the current salary.
To make this simpler, the
condition block exists.
A condition block has a condition and a begin and end, and everything between the begin and end will be done if the condition is true.
For our example, this will look as follows in the action list:
You can add your own condition blocks through
[ACTIONS > Block] under the subsection
Doing so will add two actions: the begin and the end.
The begin part of the block can be edited to change the condition.
If you want to put actions in the block, you can drag them inside the block or use the arrows in the action list to move actions up or down.