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>. | + | As explained in the [[Variables]] section, variables are divided into '''2 categories''' and '''4 types'''. Whatever category or type, their value/content is never reset and remains, even after device reboot. They are identified by a '''name''' given at creation time ''(see below)'' |
| | | |
| | | |
− | <strong>— Naming:</strong>
| + | '''Naming:''' |
| + | |
| 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. | | 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>.
| + | '''Category:''' |
− | * 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 | + | Every variable can be either '''local''' or '''global'''. |
| + | * A '''local variable''' 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 '''global variable''' can be accessed and used from any macro. Its name must be unique among all the 'global' variables |
| + | |
| | | |
| + | '''Type:''' |
| | | |
− | <strong>— Type:</strong>
| + | A variable can belong to 1 of the 4 following types: '''Boolean, Integer, Decimal''' or '''String'''. |
− | A variable can belong to 1 of the 4 following types: <strong>Boolean, Integer, Decimal</strong> or <strong>String</strong>. | + | *'''Boolean''' type allows 2 states: True or False |
− | * <strong>Boolean</strong> type allows 2 states: True or False | + | *'''Integer''' type is to store positive or negative numbers without decimal part, in order to make any kind of mathematical calculations or comparison |
− | * <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 | + | *'''Decimal''' 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>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 | + | *'''String''' type contains any kind of character (alphanumeric ones or any special ones, such as line feed/carriage return/new line or emojis). ''HINT: an individual string variable can hold up to 500,000 characters, however it is advisable to avoid very long strings where possible. If you should use strings of great length it is recommended to clear them when finished with.'' |
− | * <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). <i>HINT: an individual string variable can hold up to 500,000 characters, however it is advisable to avoid very long strings where possible. If you should use strings of great length it is recommended to clear them when finished with.</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>.
| + | '''"Set variable" action''' 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 ''[New Variable]''. In this case, you'll be asked what category, name and type have to be assigned to this new variable ''(see above)''. |
| | | |
− | According to its type <i>(see above)</i>, you can choose a value or method to be assigned to among a list of methods: | + | According to its type ''(see above)'', you can choose a value or method to be assigned to among a list of methods: |
| | | |
− | <strong>— For Boolean variables:</strong>
| + | '''For Boolean variables:''' |
| * False or True value | | * False or True value |
| * invert current value | | * invert current value |
| * prompt at execution time | | * prompt at execution time |
− | * another variable value | + | * another boolean variable value |
| | | |
− | <strong>— For Numeric variables (Integer or Decimal):</strong>
| + | '''For Numeric variables (Integer or Decimal):''' |
| * fixed value | | * fixed value |
| * random value | | * random value |
| * prompt at execution time | | * prompt at execution time |
− | * mathematical expression | + | * mathematical expression that can include any existing numeric or boolean variable as well as any available numeric [[Magic text]] |
| * 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) | | * 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>
| + | '''For String variables:''' |
− | * fixed value (including concatenated string variables contents) | + | * fixed value (including concatenated string variables contents as well as any available [[Magic text]] or empty string to clear the variable content) |
| * prompt at execution time | | * prompt at execution time |