action:Set_Variable_to_Calculation
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| action:Set_Variable_to_Calculation [2016/03/30 07:09] – [Set Variable to Calculation Action] peternlewis | action:Set_Variable_to_Calculation [2023/11/11 03:40] (current) – [Formatting] peternlewis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | {{: | ||
| ====== Set Variable to Calculation Action ====== | ====== Set Variable to Calculation Action ====== | ||
| The Set Variable to Calculation action sets a variable to the result of a calculation with numeric formatting. | The Set Variable to Calculation action sets a variable to the result of a calculation with numeric formatting. | ||
| - | {{: | + | {{: |
| - | **You may use the following in the //to// calculation box:** | + | |
| + | ===== Calculations ===== | ||
| + | |||
| + | You may use the following in the //to// calculation box: | ||
| * [[token: | * [[token: | ||
| * [[: | * [[: | ||
| - | * [[https://www.keyboardmaestro.com/ | + | * [[/manual/Calculations|Calculation Operators]] |
| - | The //to// field is a [[: | + | The //to// field is a [[: |
| + | ===== Variables ===== | ||
| + | |||
| + | The //to// field is a numeric field, so you use variable names unadorned: | ||
| - | **Using Keyboard Maestro Variable Names in the //to// calculation box:** | ||
| * Do **not** use the text token syntax for a Variable, like `%Variable%My Variable Name%`. | * Do **not** use the text token syntax for a Variable, like `%Variable%My Variable Name%`. | ||
| * Instead, you just use the Variable name without any `%`, like `My Variable Name` | * Instead, you just use the Variable name without any `%`, like `My Variable Name` | ||
| Line 19: | Line 24: | ||
| You can use the //Edit ➤ Insert Function// menu to insert functions. | You can use the //Edit ➤ Insert Function// menu to insert functions. | ||
| - | At the bottom of the action you can see the current value of the calculation. | + | ===== Formatting ===== |
| As can be seen by the blue shade of the action gear menu there is an additional option for the action, specifically you can //Format the Result// using [[https:// | As can be seen by the blue shade of the action gear menu there is an additional option for the action, specifically you can //Format the Result// using [[https:// | ||
| - | ===== Example | + | |
| + | (i) Note that numeric values in Keyboard Maestro allow only “full stop” decimal (.) and no thousand separators (except optional underscores), | ||
| + | |||
| + | |||
| + | ===== Result | ||
| + | |||
| + | At the bottom of the action you can see the current value of the calculation. | ||
| + | |||
| + | If the calculation is invalidly formatted, the invalid part of the calculation will show up in <color # | ||
| + | |||
| + | If the calculation would currently fail because an input variable does not currently have a numeric value, that variable will show up in <color # | ||
| + | |||
| + | ===== Examples ===== | ||
| + | |||
| + | ==== Example 1 ==== | ||
| The below macro performs a simple calculation of adding 1 to the value currently selected by the user in the user's document, and then pasting the new value back into the user's document. | The below macro performs a simple calculation of adding 1 to the value currently selected by the user in the user's document, and then pasting the new value back into the user's document. | ||
| Line 28: | Line 47: | ||
| {{: | {{: | ||
| + | ==== Example 2 ==== | ||
| + | |||
| + | {{vars-x-y-width-height.png? | ||
| ===== See Also ===== | ===== See Also ===== | ||
| - | |||
| - | ---- | ||
| ==== Actions ==== | ==== Actions ==== | ||
| - | * [[action: | + | * [[action: |
| - | * [[action: | + | * [[action: |
| * [[: | * [[: | ||
| Line 47: | Line 67: | ||
| * [[: | * [[: | ||
| - | ---- | + | ==== Tokens ==== |
| + | |||
| + | * [[token: | ||
| + | * [[token: | ||
| + | * [[: | ||
| + | |||
| + | ==== Topics ==== | ||
| + | |||
| + | * [[:Text Fields|Text Fields]] | ||
| + | * [[: | ||
| ==== Forum ==== | ==== Forum ==== | ||
| + | - [[https:// | ||
| - [[https:// | - [[https:// | ||
| - [[https:// | - [[https:// | ||
| - [[https:// | - [[https:// | ||
| + | - [[https:// | ||
| + | - [[https:// | ||
| + | - [[https:// | ||
| + | - [[https:// | ||
| - | - [[https://www.google.fr/search?q=site: | + | - [[https://forum.keyboardmaestro.com/ |
action/Set_Variable_to_Calculation.1459321769.txt.gz · Last modified: by peternlewis
