User Tools

Site Tools


action:Set_Variable_to_Calculation

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 Both sides next revision
action:Set_Variable_to_Calculation [2016/08/28 12:16]
alain add one more example about .x, .y, [1-4], etc
action:Set_Variable_to_Calculation [2016/09/20 02:38]
peternlewis
Line 4: Line 4:
 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.
  
-{{:​action:​km7-set-var-name-to-calculation-action.png?​nolink|}}\\ +{{:​action:​km7-set-var-name-to-calculation-action.png?​nolink|}} 
-**You may use the following in the //to// calculation box:**+ 
 +===== Calculations ===== 
 + 
 +You may use the following in the //to// calculation box: 
   * [[token:​Variable|Keyboard Maestro Variables]]   * [[token:​Variable|Keyboard Maestro Variables]]
   * [[:​Functions|Functions]]   * [[:​Functions|Functions]]
   * [[/​manual/​Calculations|Calculation Operators]]   * [[/​manual/​Calculations|Calculation Operators]]
  
-The //to// field is a [[:​Text_Fields|numeric field]] so you cannot use any of the [[token:​CurrentClipboard|Clipboard tokens]] or indeed any [[:​Tokens|text tokens]]. ​ +The //to// field is a [[:​Text_Fields|numeric field]] so you cannot use any of the [[token:​CurrentClipboard|Clipboard tokens]] or indeed any [[:​Tokens|text tokens]], except within a [CALCULATE](https://​wiki.keyboardmaestro.com/​function/​CALCULATE) function.
  
 +===== 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 25:
 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. ​ If the calculation is invalidly formatted, the invalid part of the calculation will show up in red.  If the calculation would currently fail because an input variable does not currently have a numeric value, that variable will show up in orange.+===== 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://​www.stairways.com/​action/​linkthru?​unicodenumberformat|Unicode Number Format Patterns]] such as //#,##​0.##//​. 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://​www.stairways.com/​action/​linkthru?​unicodenumberformat|Unicode Number Format Patterns]] such as //#,##​0.##//​.
 +
 +===== 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 red.  If the calculation would currently fail because an input variable does not currently have a numeric value, that variable will show up in orange.
  
 ===== Examples ===== ===== Examples =====
action/Set_Variable_to_Calculation.txt · Last modified: 2023/11/10 22:40 by peternlewis