CommandFusion Wiki

Documentation Resources

User Tools

Site Tools


software:gui-designer:math-expressions

Differences

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

Link to this comparison view

software:gui-designer:math-expressions [2012/08/16 04:31]
aaron
software:gui-designer:math-expressions [2015/04/09 00:58] (current)
jarrod [Numbers and text output formatting]
Line 1: Line 1:
 ====== Math Expressions ====== ====== Math Expressions ======
-Starting with version 3.4.1, ​iViewer embeds a new, powerful and versatile math expression engine. Math expressions can be inserted in commands and feedback items. The Math expression parser features:+iViewer embeds a powerful and versatile math expression engine. Math expressions can be inserted in commands and feedback items. The Math expression parser features:
   * Standard math operators   * Standard math operators
   * Parenthesis grouping   * Parenthesis grouping
Line 15: Line 15:
 \\ \\
 Within commands, math expressions must be enclosed in double curly braces, the result of the math evaluation is converted to a string (and can be optionally formatted the way you need it). Math expression can also be used in the transform field of '​capture group' feedback items (where the incoming data type is set to Analog), in which case you won't use the double curly braces to enclose the expression. Within commands, math expressions must be enclosed in double curly braces, the result of the math evaluation is converted to a string (and can be optionally formatted the way you need it). Math expression can also be used in the transform field of '​capture group' feedback items (where the incoming data type is set to Analog), in which case you won't use the double curly braces to enclose the expression.
 +
 +<WRAP center round important 90%>
 +Do NOT use the double curly braces in the ''​capture group > transform''​ property in your feedback parsing. They are not needed in the transform property because this field can **only** contain math expressions. Read the above paragraph for more details.
 +</​WRAP>​
 +
  
 <​code>​ <​code>​
Line 20: Line 25:
 Simple addition: ​      {{ 1 + [currentValue] }} Simple addition: ​      {{ 1 + [currentValue] }}
  
 +Math functions: ​       {{ round(1.5 * [currentValue]) }}
  
- Math functions: ​       {{ round(1.5 * [currentValue]) }} +Multiple expressions: ​ {{ a=100, b=2*[inputValue],​ max(a, b) }}
- +
- +
- Multiple expressions: ​ {{ a=100, b=2*[inputValue],​ max(a, b) }} +
- +
- +
- ​Conditions: ​           {{ a=[currentValue]+[delta],​ if(a<5, a=0, a) }}+
  
 +Conditions: ​           {{ a=[currentValue]+[delta],​ if(a<5, a=0, a) }}
  
- Boolean logic: ​        {{ above=([currentValue] > 100), below=([currentValue] ​ < 0), if (above or below, 0, [currentValue]) }}+Boolean logic: ​        {{ above=([currentValue] > 100), below=([currentValue] ​ < 0), if (above or below, 0, [currentValue]) }}
  
 </​code>​ </​code>​
Line 51: Line 52:
 Math expressions can also be used in feedback '​capture group' items, within the transform field. This works same as above, but you don't have to wrap the expression in curly braces.\\ Math expressions can also be used in feedback '​capture group' items, within the transform field. This works same as above, but you don't have to wrap the expression in curly braces.\\
 \\ \\
-With transforms, one predefined constant is set ("​value"​) which is the value extracted from the capture group, and can be used in the math computation.+With transforms, one predefined constant is set ("​value"​) which is the value extracted from the capture group, and can be used in the math computation.\\ 
 +<WRAP center round tip 80%> 
 +Note that the '​value'​ constant does not support decimal values when using an Analog data type. The constant will always be rounded to a whole number before any transform can take place.\\ 
 +So you need to capture it into a serial join first, then use [[#​referencing-other-groups|capture group name referencing]] to perform any math on this value if you need the initial captured value to support decimals. 
 +</​WRAP>​
  
  
software/gui-designer/math-expressions.1345091473.txt.gz · Last modified: 2012/08/16 04:31 by aaron