Changes

3,118 bytes added ,  11:38, 21 June 2021
no edit summary
Line 1: Line 1:  
This action allows you to set the value of a specific MacroDroid variable.
 
This action allows you to set the value of a specific MacroDroid variable.
 +
 +
As explained in the [[Variables]] section, variables are divided into <strong>2 categories</strong> and <strong>4 types</strong>. Whatever category or type, their value/content is never reset and remains, even after device reboot. They are identified by a <strong>name</strong> given at creation time <i>(see below)</i>.
 +
 +
 +
<strong>— Naming:</strong>
 +
Every variable is identified by its name. This name can be made of any set of character. To facilitate maintainability, the name should relate the content or purpose of the named variable.
 +
 +
 +
<strong>— Category:</strong> Every variable can be either <strong>local</strong> or <strong>global</strong>.
 +
* A <strong>local variable</strong> belongs to the macro it has been created into. It can only be used inside this macro. Its name must be unique inside the macro it belongs to
 +
* A <strong>global variable</strong> can be accessed and used from any macro. Its name must be unique among all the 'global' variables
 +
 +
 +
<strong>— Type:</strong>
 +
A variable can belong to 1 of the 4 following types: <strong>Boolean, Integer, Decimal</strong> or <strong>String</strong>.
 +
* <strong>Boolean</strong> type allows 2 states: True or False
 +
* <strong>Integer</strong> type is to store positive or negative numbers without decimal part, in order to make any kind of mathematical calculations or comparison
 +
* <strong>Decimal</strong> type is to store any positive or negative numeric value, with or without decimal digits, in order to make any kind of mathematical calculations or comparison
 +
* <strong>String</strong> type contains any kind of character (alphanumeric ones or any special ones, such as line feed/carriage return/new line or emojis). The amount of characters a string variable can contain depends on your memory device capacity. <i>HINT: to avoid memory saturation with string variables containing a huge amount of data, it's better to reset them (set to empty string) at the end of the macro using them.</i>
 +
 +
 +
<strong>'Set variable' action</strong> allows to store a specific value to a given variable. This variable has to be selected among all the available variables or created by selecting the first item of the list called <i>[New Variable]</i>. In this case, you'll be asked what category, name and type have to be assigned to this new variable <i>(see above)</i>.
 +
 +
According to its type <i>(see above)</i>, you can choose a value or method to be assigned to among a list of methods:
 +
 +
<strong>— For Boolean variables:</strong>
 +
* False or True value
 +
* invert current value
 +
* prompt at execution time
 +
* another variable value
 +
 +
<strong>— For Numeric variables (Integer or Decimal):</strong>
 +
* fixed value
 +
* random value
 +
* prompt at execution time
 +
* mathematical expression
 +
* in addition, Integer type variables have 2 other kinds of settings: adding or subtracting 1 to current value (same as mathematical expression 'my_integer_variable +/- 1' but more convenient when incrementing/decrementing an index by step of 1)
 +
 +
<strong>— For String variables:</strong>
 +
* fixed value (including concatenated string variables contents)
 +
* prompt at execution time
editors
58

edits