Difference between revisions of "Control flow: If clause"

Line 24: Line 24:
 
==<p><b>MacroDroid Variable/Compare Values</b></p>==
 
==<p><b>MacroDroid Variable/Compare Values</b></p>==
  
===  =  ===
+
== About ==
  
 
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
 
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
Means that the whole content of the string variable has to be equal to the whole set of typed characters.
+
This action allows you to adjust how bright or dim the screen of your phone looks. For example, if you are in a dark place, you can use this action to make the screen brighter so that you can see better.
 +
</pre><br/>
 +
 
 +
==<p><b>Configuration available</b></p>==
 +
 
 +
=== Auto Brightness ===
 +
 
 +
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
 +
You can choose the percentage when automatic brightness is activated.
 +
</pre><br>
 +
 
 +
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
 +
You can set the status of the automatic brightness level (Off-On).
 +
</pre><br/>
 +
 
 +
=== Slider value ===
 +
 
 +
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
 +
You can choose to choose a fixed value with the slider or choose a value of some integer type variable.
 
</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) '''''
+
''''' [https://macrodroidforum.com/wiki/index.php/Variables#Integer Variables | Integer ] '''''
<br>
+
<br/>
 +
 
 +
=== Alternative Android 9+ mode ===
 +
 
 +
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
 +
The brightness control may not work as expected on some newer Android devices (Android 9+). Try to enable this option.
 +
</pre><br/>
 +
 
 +
=== Force value ===
 +
 
 +
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
 +
On some devices, especially Xiaomi, brightness control is different. Use this option to set a specific brightness level, even above 100%.
 +
</pre><br>
 +
 
 +
==<p><b>Example</b></p>==
 +
 
 +
<pre style="background-color: #AC2424; color: white; border-radius: 10px; padding: 10px;">
 +
Triggers
 +
 
 +
Battery>=50%
 +
</pre><br>
 +
<pre style="background-color: #1665B0; color: white; border-radius: 10px; padding: 10px;">
 +
Actions
 +
 
 +
Brightness
 +
Auto
 +
</pre><br>
 +
<pre style="background-color: green; color: white; border-radius: 10px; padding: 10px;">
 +
Constraints
 +
 
 +
 
 +
</pre><br>
 +
<pre style="background-color: teal; color: white; border-radius: 10px; padding: 10px;">
 +
Local variables
 +
 
 +
</pre><br>
  
 
===  != ===
 
===  != ===

Revision as of 23:28, 10 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

About

This action allows you to adjust how bright or dim the screen of your phone looks. For example, if you are in a dark place, you can use this action to make the screen brighter so that you can see better.


Configuration available

Auto Brightness

You can choose the percentage when automatic brightness is activated.


You can set the status of the automatic brightness level (Off-On).


Slider value

You can choose to choose a fixed value with the slider or choose a value of some integer type variable.

Variables | Integer

Alternative Android 9+ mode

The brightness control may not work as expected on some newer Android devices (Android 9+). Try to enable this option.


Force value

On some devices, especially Xiaomi, brightness control is different. Use this option to set a specific brightness level, even above 100%.


Example

Triggers

Battery>=50%


Actions

Brightness
Auto


Constraints



Local variables


!=

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).