User Tools

Site Tools


manual:Variables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
manual:Variables [2019/06/19 03:41]
peternlewis [Watching a Variable’s Value]
manual:Variables [2019/09/14 18:18] (current)
JMichaelTX
Line 4: Line 4:
  
 Variables can be set from many actions. ​ You can set variables to specific [[manual:​Tokens| tokenised]] text, to the result of a [[manual:​Calculations| calculations]],​ from user input, from the Keychain, by searching other variables, from the [[token:​CurrentClipboard| clipboard]] or [[token:​NamedClipboard|Named Clipboards]],​ as the result of [[:​Scripting|scripts]],​ and from many other sources. Variables can be set from many actions. ​ You can set variables to specific [[manual:​Tokens| tokenised]] text, to the result of a [[manual:​Calculations| calculations]],​ from user input, from the Keychain, by searching other variables, from the [[token:​CurrentClipboard| clipboard]] or [[token:​NamedClipboard|Named Clipboards]],​ as the result of [[:​Scripting|scripts]],​ and from many other sources.
 +
 +===== Variable Naming Rules =====
 +
 +Anywhere an [[:​Actions|Action]] requires a Variable, you can enter any name you like (even though often  a default name is provided), as long as it conforms to these rules:
 +  - Variable names must start with a letter, and then can contain letters, numbers, spaces, or underscores.
 +  - Some Variable kinds require a specific prefix (see _Scope_ below).
 +  - Variable names are case insensitive,​ but their case is remembered.
 +  - Variable names should not include a function or operator name with spaces around it.
 +     *(eg “ MOD ” , so “A MOD B” would not be a valid variable, although “MODULE” would be fine).
 +
  
 ===== Scope ===== ===== Scope =====
Line 13: Line 23:
 | **Global**, Permanent variables | • Accessible basically everywhere, including Scripts.\\ • You can also see and edit variables in the Preferences.\\ • You can see global variables in the [[Windows#​Value_Inspector_Window |Value Inspector]]. | | **Global**, Permanent variables | • Accessible basically everywhere, including Scripts.\\ • You can also see and edit variables in the Preferences.\\ • You can see global variables in the [[Windows#​Value_Inspector_Window |Value Inspector]]. |
 | **Password**,​ Semi-permanent variables | • Available to macros but not displayed.\\ • Not directly accessible via AppleScript.\\ • Concealed in password fields in Prompt For User Input actions.\\ • Not saved to disk. | | **Password**,​ Semi-permanent variables | • Available to macros but not displayed.\\ • Not directly accessible via AppleScript.\\ • Concealed in password fields in Prompt For User Input actions.\\ • Not saved to disk. |
-| **Instance** Variables (v8+) | • Restricted ​ to a specific execution sequence.\\ • Available to the Macro where it was created and Sub-Macros of that Macro, for a given execution instance of the main macro.\\ • These Variables are private to each execution of the same Macro, even when running simultaneously.\\ • Accessible by [[action:​Prompt_for_User_Input|Prompt For User Input]]\\ • As of v8.0.3, is accessible by scripts (when used in an Execute Script Action).\\ • Accessible by [[action:​Custom_HTML_Prompt|Custom HTML Prompt]] (v8.0.3+).\\ • Accessible by AppleScript with the instance specifier. | +| **[[#​Instance_Variables_v8|Instance]]** Variables (v8+)\\ Auto-deleted when Macro terminates ​• Name must begin with "​instance"​ (case insensitive).\\ ​• Restricted ​ to a specific execution sequence.\\ • Available to the Macro where it was created and Sub-Macros of that Macro, for a given execution instance of the main macro.\\ • These Variables are private to each execution of the same Macro, even when running simultaneously.\\ • Accessible by [[action:​Prompt_for_User_Input|Prompt For User Input]]\\ • As of v8.0.3, is accessible by scripts (when used in an Execute Script Action).\\ • Accessible by [[action:​Custom_HTML_Prompt|Custom HTML Prompt]] (v8.0.3+).\\ • Accessible by AppleScript with the instance specifier. | 
-| **Local** Variables (v8+) | • Restricted to the specific Macro it is in.\\ • //Not// available to any of its Sub-Macros\\ • Same accessibility as Instance Variables. |+| **[[#​Local_Variables_v8|Local]]** Variables (v8+)\\ Auto-deleted when Macro terminates ​• Name must begin with "​local"​ (case insensitive)\\ ​• Restricted to the specific Macro it is in.\\ • //Not// available to any of its Sub-Macros\\ • Same accessibility as Instance Variables. |
 | **[[manual:​Dictionaries|Dictionary]]**,​ Permanent, global in scope. | • Accessible basically Everywhere, including Scripts.\\ • Dictionaries consist of the //​Dictionary Name//, One or more pairs of //Key Name//, and //​Value//​.\\ • Although Dictionaries are sort of like structured //​Variables//,​ they are kept in a separate category called //​[[manual:​Dictionaries|Dictionaries]]//​. | | **[[manual:​Dictionaries|Dictionary]]**,​ Permanent, global in scope. | • Accessible basically Everywhere, including Scripts.\\ • Dictionaries consist of the //​Dictionary Name//, One or more pairs of //Key Name//, and //​Value//​.\\ • Although Dictionaries are sort of like structured //​Variables//,​ they are kept in a separate category called //​[[manual:​Dictionaries|Dictionaries]]//​. |
  
Line 28: Line 38:
  
 Global Variables are permanently stored on your Mac drive (like a file), and are available for read/write in any Macro or Action, not just the Macro where the Variable was created. ​ These variables persist between logins and restarts of your Mac. Global Variables are permanently stored on your Mac drive (like a file), and are available for read/write in any Macro or Action, not just the Macro where the Variable was created. ​ These variables persist between logins and restarts of your Mac.
- 
-Variable names must start with a letter, and then can contain letters, numbers, spaces, or underscores. ​ Variable names are case insensitive,​ but their case is remembered. Variable names should not include a function or operator name with spaces around it (eg " MOD " , so "A MOD B" would not be a valid variable, although "​MODULE"​ would be fine). 
  
 ==== Password Variables ==== ==== Password Variables ====
Line 37: Line 45:
 ==== Instance Variables (v8+) ==== ==== Instance Variables (v8+) ====
  
-Variables with names that start with "​Instance"​ (trailing space not necessary) are considered private to a specific execution sequence. ​ Each time the macro is run, they will start empty but their value can be seen and changed by other macros within the same execution sequence (for example, if you execute a macro using the [[action:​Execute_a_Macro|Execute Macro]] action, that macro can see and change the instance variable). ​ Since two instances of a macro can be running at the same time, this is useful to ensure they each have their own version of the variable.+Variables with names that start with "​Instance"​ (case insensitive, ​trailing space not necessary) are considered private to a specific execution sequence. ​ Each time the macro is run, they will start empty but their value can be seen and changed by other macros within the same execution sequence (for example, if you execute a macro using the [[action:​Execute_a_Macro|Execute Macro]] action, that macro can see and change the instance variable). ​ Since two instances of a macro can be running at the same time, this is useful to ensure they each have their own version of the variable.
  
 Since Local and Instance variables are transient, they are not shown in the [[manual:​Preferences#​Variables_Preferences| Variables preferences pane]]. Since Local and Instance variables are transient, they are not shown in the [[manual:​Preferences#​Variables_Preferences| Variables preferences pane]].
Line 44: Line 52:
 ==== Local Variables (v8+) ==== ==== Local Variables (v8+) ====
  
-Variables with names that start with "​Local"​ (trailing space not necessary) are considered local to a specific execution of a specific macro. ​ Each time the macro is run, they will start empty and no other macro will see or be able to change values.+Variables with names that start with "​Local"​ (case insensitive, ​trailing space not necessary) are considered local to a specific execution of a specific macro. ​ Each time the macro is run, they will start empty and no other macro will see or be able to change values.
  
 **Note that //Local// and //​Instance//​ Variables are available in scripts //only// when the script is called in an //Execute Script// action, ** unless you specify the execution instance explicitly. **Note that //Local// and //​Instance//​ Variables are available in scripts //only// when the script is called in an //Execute Script// action, ** unless you specify the execution instance explicitly.
manual/Variables.1560930061.txt.gz · Last modified: 2019/06/19 03:41 by peternlewis