(27 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Variables can be used to store values (numbers, text strings and true/false conditions). These values can be set in the Macrodroid action “Set variable”. Variables can be used throughout the app as Triggers and Conditions, and can be used for controlling specific Macrodroid and system settings.
+
<span style="color: #00828f; font-size: 24px; display: inline-block; margin-top: 15px; margin-bottom: 0px;"><strong>About variables</strong></span>
  
<strong>Global Variables</strong>
+
Variables can be used to store values (numbers, text strings and true/false conditions). These values can be set in the Set Variable Action. Variables can be used throughout the app as Triggers and Conditions, and can be used for controlling specific Macrodroid and system settings.
 +
</pre>
 +
'' An introduction video is available here ''
 +
https://www.youtube.com/watch?v=0V_EcyhxrpA&t=1s
 +
<br>
  
Global variables are available throughout the application from any Macro. You should use global variables when you need to store a value between more than a single macro.
+
==<p><b>Global / Local Variables </b></p>==
  
<strong>Local Variables</strong>
+
=== Local ===
  
Local variables are specific to an individual macro. You should use a local variable when the value is only required in that individual macro.
+
'''Simplified:'''
  
<strong>Variable Types</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 variable can belong to 1 of the 4 following types: <strong>Boolean, Integer, Decimal</strong> or <strong>String</strong>.
+
'''Advanced:'''
* <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
+
Local variables are specific to a single macro. Use them only when the value is required within that macro. Local variables can be accessed through the edit macro screen.
* <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: 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>
+
 
 +
=== Global ===
 +
 
 +
'''Simplified:'''
 +
 
 +
Can be accessed and used from any macro. Its name must be unique among all the 'global' variables
 +
 
 +
'''Advanced:'''
 +
 
 +
Global variables are accessible throughout the application from any Macro. They should be used when storing a value between multiple macros. The list of global variables can be accessed via the Variables tile on the home screen, where you can add, delete, and modify their values.
 +
 
 +
==<p><b>Standard Variable Types</b></p>==
 +
 
 +
=== Boolean ===
 +
 
 +
allows 2 states: True or False.
 +
 
 +
=== Integer ===
 +
 
 +
to store positive or negative numbers without decimal part, in order to make any kind of mathematical calculations or comparison.
 +
 
 +
=== Decimal ===
 +
 
 +
to store any positive or negative numeric value, with or without decimal digits, in order to make any kind of mathematical calculations or comparison. Sientific notation as 1.3E-2 may be used.
 +
 
 +
=== String ===
 +
 
 +
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.
 +
 
 +
==<p><b>Data Structure Variable Types</b></p>==
 +
 
 +
=== Array ===
 +
 
 +
stores a series of values with associated index variables. For example if you wanted to store a count for each day of the month you could create an array called dayOfMonthCount and have a series of entries such as dayOfWeekCount[1] = 5, dayOfWeekCount[2] = 2 etc.
 +
 
 +
=== Dictionary ===
 +
 
 +
stores a series of key value pairs. For example if you wanted to store a count for each day of the week you could create a dictionary called dayOfWeekCount and have a series of entries such as dayOfWeekCount [monday] = 1, dayOfWeekCount [tuesday] = 3 etc.

Latest revision as of 16:47, 23 April 2024

About variables

Variables can be used to store values (numbers, text strings and true/false conditions). These values can be set in the Set Variable Action. Variables can be used throughout the app as Triggers and Conditions, and can be used for controlling specific Macrodroid and system settings.

An introduction video is available here https://www.youtube.com/watch?v=0V_EcyhxrpA&t=1s

Global / Local Variables

Local

Simplified:

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.

Advanced:

Local variables are specific to a single macro. Use them only when the value is required within that macro. Local variables can be accessed through the edit macro screen.


Global

Simplified:

Can be accessed and used from any macro. Its name must be unique among all the 'global' variables

Advanced:

Global variables are accessible throughout the application from any Macro. They should be used when storing a value between multiple macros. The list of global variables can be accessed via the Variables tile on the home screen, where you can add, delete, and modify their values.

Standard Variable Types

Boolean

allows 2 states: True or False.

Integer

to store positive or negative numbers without decimal part, in order to make any kind of mathematical calculations or comparison.

Decimal

to store any positive or negative numeric value, with or without decimal digits, in order to make any kind of mathematical calculations or comparison. Sientific notation as 1.3E-2 may be used.

String

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.

Data Structure Variable Types

Array

stores a series of values with associated index variables. For example if you wanted to store a count for each day of the month you could create an array called dayOfMonthCount and have a series of entries such as dayOfWeekCount[1] = 5, dayOfWeekCount[2] = 2 etc.

Dictionary

stores a series of key value pairs. For example if you wanted to store a count for each day of the week you could create a dictionary called dayOfWeekCount and have a series of entries such as dayOfWeekCount [monday] = 1, dayOfWeekCount [tuesday] = 3 etc.