Difference between revisions of "Control flow: If clause"

 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
  
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
 
If statement
 
  
This action allows to execute a set of subsequent actions according to specific condition(s).
+
''' If statement '''
 +
 
 +
The '''If''' statement is available form the ‘Add Action’ menu part ‘Conditions/Loops’ and comes along with a terminating '''End IF'''.
 +
 
 +
This action allows to execute a set of subsequent actions according to specific condition(s). The possible conditions are the same as constraints and are tested in exactly the same way, with logical connectors 'AND' (default one) or 'OR' in case of multiple conditions.
 +
 
 +
In case the condition is met and a number of subsequent actions should be executed while different actions should be executed if the condition was not met an '''Else''' statement has to be implemented.
 +
 
 +
''' Else statement '''
  
The possible conditions are the same as constraints and are tested in exactly the same way, with logical connectors 'AND' (default one) or 'OR' in case of multiple conditions.
+
'''Else''' will only become available by selecting the '''If''' statement again and then selecting the ‘Add else clause’ from the ‘Set Variable’ menu.
If statement
+
In case further constrains should be invoked ‘Add else/If clause’ or ‘Add else/If confirmed clause’ can be used.
  
The ‘If’ statement is available form the ‘Add Action’ menu part ‘Conditions/Loops’.
+
'''If''' statements my be nested that is within '''If''' and '''End If'''  there might be other pairs of '''If''' and '''End If'''.
An ‘If’ statement needs one or more conditions to be fulfilled to be activated and is
 
terminated by ‘End If’. The code in between is only executed in case the condition is met.
 
The possible conditions are the same as constrains and are tested in exactly the same way with
 
logical connectors as ‘AND’ (default one) or ‘OR’.
 
In case the condition is met and a number of subsequent actions should be executed while
 
different actions should be executed if the condition was not met an ‘Else’ statement has to be
 
implemented. ‘Else’ will only become available by selecting the ‘If’ statement again and
 
select ‘Add else clause’ from the ‘Set Variable’ menu.
 
In case further constrains should be invoked ‘Add else/If clause’ or ‘Add else/If confirmed
 
clause’ can be used.
 
‘If’ statements my be nested that is within ‘If’ and ‘End If there might be other pairs of ‘If’
 
and ‘End If .
 
  
Files
 
The available file handling is self explanatory. However care should be given to the fact that
 
especially write commands will need some time before the action is concluded. It may be a
 
good idea to place a subsequent ‘Wait’ statement before trying to read what was written.
 
  
 
</pre>
 
</pre>
Line 39: Line 29:
 
Means that the whole content of the string variable has to be equal to the whole set of typed characters.
 
Means that the whole content of the string variable has to be equal to the whole set of typed characters.
 
</pre>
 
</pre>
''''' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#Standard_Variable_Types Variables | String, Integer, Decimal, Boolean] (Boolean only in the compare values condition/constraints) '''''
+
'' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#Standard_Variable_Types Variables | String, Integer, Decimal, Boolean] (Boolean only in the compare values condition/constraints) ''
 
<br>
 
<br>
  
Line 47: Line 37:
 
Means that the content of the string variable has to be unequal (i.e. different) to the set of typed characters.
 
Means that the content of the string variable has to be unequal (i.e. different) to the set of typed characters.
 
</pre>
 
</pre>
''''' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#Standard_Variable_Types Variables | String, Integer, Decimal, Boolean] (Boolean only in the compare values condition/constraints) '''''
+
'' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#Standard_Variable_Types Variables | String, Integer, Decimal, Boolean] (Boolean only in the compare values condition/constraints) ''
 
<br>
 
<br>
  
Line 55: Line 45:
 
Means that the content of the string variable has to contain the whole set of typed character. For instance, enter the word information to match with a string variable containing the text: Here are the informations you asked for...
 
Means that the content of the string variable has to contain the whole set of typed character. For instance, enter the word information to match with a string variable containing the text: Here are the informations you asked for...
 
</pre>
 
</pre>
''''' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#String Variables | String ''''']
+
'' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#String Variables | String '']
 
<br>
 
<br>
  
Line 63: Line 53:
 
Means that the content of the string variable has not to contain the typed text.
 
Means that the content of the string variable has not to contain the typed text.
 
</pre>
 
</pre>
''''' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#String Variables | String] '''''
+
'' Compatible with [https://macrodroidforum.com/wiki/index.php/Variables#String Variables | String] ''
 
<br>
 
<br>
  
Line 70: Line 60:
 
=== '''  *''' ===
 
=== '''  *''' ===
 
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
 
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
'''*''' stands for any number of character (from 0 to any, same as '.*' in Regex).
+
* stands for any number of character (from 0 to any, same as '.*' in Regex).
 
</pre><br>
 
</pre><br>
  
 
=== ? ===
 
=== ? ===
 
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
 
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
'''?''' is for 1 and only 1 mandatory character (same as '.{1}' in Regex).
+
? is for 1 and only 1 mandatory character (same as '.{1}' in Regex).
 
</pre><br>
 
</pre><br>
  
 
* '''Tick the box '''Enter regular expression matching''' if the typed text follows Regex syntax, far more powerful than plain text with or without wildcards (for advanced users).'''
 
* '''Tick the box '''Enter regular expression matching''' if the typed text follows Regex syntax, far more powerful than plain text with or without wildcards (for advanced users).'''

Latest revision as of 21:21, 23 January 2024

Introduction

If statement

The If statement is available form the ‘Add Action’ menu part ‘Conditions/Loops’ and comes along with a terminating End IF.

This action allows to execute a set of subsequent actions according to specific condition(s). The possible conditions are the same as constraints and are tested in exactly the same way, with logical connectors 'AND' (default one) or 'OR' in case of multiple conditions.

In case the condition is met and a number of subsequent actions should be executed while different actions should be executed if the condition was not met an Else statement has to be implemented.

Else statement

Else will only become available by selecting the If statement again and then selecting the ‘Add else clause’ from the ‘Set Variable’ menu. In case further constrains should be invoked ‘Add else/If clause’ or ‘Add else/If confirmed clause’ can be used.

If statements my be nested that is within If and End If there might be other pairs of If and End If.


Constraints

MacroDroid Variable/Compare Values

=

Means that the whole content of the string variable has to be equal to the whole set of typed characters.

Compatible with Variables | String, Integer, Decimal, Boolean (Boolean only in the compare values condition/constraints)

!=

Means that the content of the string variable has to be unequal (i.e. different) to the set of typed characters.

Compatible with Variables | String, Integer, Decimal, Boolean (Boolean only in the compare values condition/constraints)

Contains

Means that the content of the string variable has to contain the whole set of typed character. For instance, enter the word information to match with a string variable containing the text: Here are the informations you asked for...

Compatible with Variables | String

Excludes

Means that the content of the string variable has not to contain the typed text.

Compatible with Variables | String

The wildcards '*' and '?'

*

* stands for any number of character (from 0 to any, same as '.*' in Regex).


?

? is for 1 and only 1 mandatory character (same as '.{1}' in Regex).


  • Tick the box Enter regular expression matching if the typed text follows Regex syntax, far more powerful than plain text with or without wildcards (for advanced users).