Robin includes two alternatives with which you may set the automations to decide the flow depending on set rules.
Using the If - else model, you may set a predefined condition under which a set of actions will be performed.
In the example below, the first set of actions will be executed when variable i is true. The second set of actions will be executed in case the variable is false. There is a third set of actions that will be performed if variables’s i value is anything else.
Note that the if statement always need to be followed by the then statement.
if i = 'true' then # Steps to perform if i is true else if i ='false' then # Steps to perform if i is false else # Steps to perform if i has any other value end
Note, that any action which provides a boolean variable result can be used within an if conditional using parenthesis ().
In the example below, the file exists action is used.
if(file.Exists File: "C:\file.txt") then # Steps to perform if file.txt exists else # Steps to perform if file.txt does not end
In order to close the conditional block, the “end” statement is required.
The alternative way to use conditions, is using the “Switch - Case” model.
In the switch - case model you need to set the variable which is calculated, and then set the actions to be performed for each case.
In the example below, the day of week is checked if it is a Weekend and accordingly the automation steps are performed.
switch DayofWeek case = 'Saturday' # Steps to perform during the weekend case = 'Sunday' # Steps to perform during the weekend default # Steps to perform during the weekdays end
A switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for executing particular actions when none of the cases are true. When the variable being switched on is equal to a case, the statements of that case will execute and all the following cases will be ignored.
As in the “If - else” model, the condition block needs to be closed using the “end” statement.