Line 12: |
Line 12: |
| | | |
| In some cases you may have common repeated functionality spread throughout multiple macros, for example you may set the brightness low and volume to zero at night time (using day/time trigger) in one macro. You may also wish to do the same elsewhere in another macro (for example using a location trigger when you are at the cinema). By grouping these actions into an action block you can call just a single action to invoke the action block. If you later decide to tweak these settings then you can just update the action block and avoid updating the settings in multiple places. | | In some cases you may have common repeated functionality spread throughout multiple macros, for example you may set the brightness low and volume to zero at night time (using day/time trigger) in one macro. You may also wish to do the same elsewhere in another macro (for example using a location trigger when you are at the cinema). By grouping these actions into an action block you can call just a single action to invoke the action block. If you later decide to tweak these settings then you can just update the action block and avoid updating the settings in multiple places. |
| + | |
| + | == Kinds of variables used == |
| + | |
| + | Three kinds of variables can be used inside an action block: Input, Output and Working ones. Each one can be of any type (boolean, integer, decimal, string, array/dictionary). |
| + | |
| + | All these variables are implicitly local and their lifetime is limited to action block execution. Their default values (see below) will be restored at the end of the execution so it is not possible to retreive previous values from a previous run (except when using Global variables). |
| | | |
| == Input and Output Parameters == | | == Input and Output Parameters == |
Line 19: |
Line 25: |
| For example suppose you wanted to convert from Celsius to Fahrenheit from within multiple macros. You could create an action block to do this that will take in an input parameter in Celsius and return an output parameter in Fahrenheit. The input parameters are available as local variables anywhere it makes sense to read a value. For example you can access the local variable in a pop up message, or in an expression when setting another variable value. The output variables are available as local variables anywhere it makes sense to set the value. For example in the set variable action you can assign to any output parameter. | | For example suppose you wanted to convert from Celsius to Fahrenheit from within multiple macros. You could create an action block to do this that will take in an input parameter in Celsius and return an output parameter in Fahrenheit. The input parameters are available as local variables anywhere it makes sense to read a value. For example you can access the local variable in a pop up message, or in an expression when setting another variable value. The output variables are available as local variables anywhere it makes sense to set the value. For example in the set variable action you can assign to any output parameter. |
| | | |
− | Each input parameter will specify a default value and this value will be set in the case where you run a local test of the action block. Likewise all output parameters define a default value. In the case that the action block doesn't set an explicit value on an output parameter, it's default value will be returned. | + | Each input parameter will specify a default value and this value will be set in the case where you run a local test or if you do not specify an input value when calling the action block from a macro. Likewise all output parameters define a default value. In the case that the action block doesn't set an explicit value on an output parameter, it's default value will be returned. |
| | | |
| When calling the action block you can specify what values will be passed in as input parameters and assign variables (either local or global) to capture the returned output parameters. You can also ignore any or all return parameters if you desire. | | When calling the action block you can specify what values will be passed in as input parameters and assign variables (either local or global) to capture the returned output parameters. You can also ignore any or all return parameters if you desire. |