User Tools

Site Tools


token:Calculate

Differences

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

Link to this comparison view

Next revision
Previous revision
token:Calculate [2015/07/15 10:24] – created peternlewistoken:Calculate [2023/11/10 03:29] (current) peternlewis
Line 1: Line 1:
-The //%Calculate%1+2%// token returns the result of performing a calculation.+===== Calculate Token =====
  
-This allows you to include any [function](:Functions) in a text field.+The //%Calculate%//**<formula>**//%// [[:Tokens|token]] returns the **numeric** result of performing a calculation, 
 +where //**`<formula>`**// may be any of the following: 
 +  * Mathematical formula like `(2 + 3)*12` 
 +  * Use any [[token:Variable|Variable]] which may be evaluated as a number 
 +    * :!:  Just enter the Variable Name (without the `%`) in the Calculate token **`<formula>`** 
 +    * Examples: 
 +      * `%Calculate%MyVar + 1%` 
 +      * `%Calculate%(MyVarWordsPerSec * 60)/MyVarWordsPerPage%` 
 +  * Use any of the built-in Keyboard Maestro [functions](:Functions), like [[function:RANDOM|RANDOM(10)]] 
 +  * Get the numeric value of an Variable array element, like `MyVar[2]`, if MyVar is `10,05,12,08` returns `5` (Arrays may contain only numeric data) 
 + 
 +The //%Hex2%// token (v8+) returns the value in Hex format, padded with zeros to two digits "2" is just an example, you can use //%Hex8%// for example. 
 + 
 +The //%Dec2%// token (v8+) returns the value in decimal format, padded with zeros to two digits (similarly //%Dec5%// to five digits, etc). 
 + 
 +The //%Oct3%// token (v8+) returns the value in octal format, padded with zeros to three digits (similarly //% Oct5%// to five digits, etc). 
 + 
 +The //%Bin8%// token (v8+) returns the value in binary format, padded with zeros to eight digits (similarly //% Bin16%// to 16 digits digits, etc). 
 + 
 +**Example Action** 
 + 
 +{{:token:km-7.3-calculate-token-example.png?nolink|}} 
 + 
 +A reminder that the following are only equivalent if the [[token:Variable|Variable]] is numeric: 
 + 
 +* %Variable%Count% (Variable) 
 +* %Calculate%Count% (Number) 
 + 
 +So, if MyVar is "`005`", then\\   
 +  * %Variable%MyVar% will return `005` 
 +  * %Calculate%MyVar% will return `5` 
 + 
 +===== See Also ===== 
 + 
 +==== Actions ==== 
 + 
 +* [[action:Set_Variable_to_Calculation|Set Variable to Calculation]] action 
 +* [[:Actions|See all Actions]] 
 + 
 +=== Tokens === 
 + 
 +* [[token:CalculateFormat|%CalculateFormat%]] token 
 +* [[/Tokens|All Tokens]]
token/Calculate.1436955867.txt.gz · Last modified: by peternlewis

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki