From wiki.ginstr.com
Jump to: navigation, search
m (formatting)
Line 3: Line 3:
 
[[Category:Action_Library]]
 
[[Category:Action_Library]]
  
;Description: Action used to perform calculation operations on different actors and stores result in target. If calculations with trigonometric functions give the wrong results, please note that the trigonometric variables input is expressed in '''radians''', not degrees. By default, the format of calculation result on [[GnEditText]] is set to <code>0.00</code>. If result needs to be formatted differently, check attribute <code>[[GnEditText#gn:decimalFormat|gn:s_decimalFormat]]</code> on [[GnEditText]]
+
;Description: Action used to perform calculation operations on different actors and stores result in target.
 +
 
 +
:If calculations with trigonometric functions give the wrong results, please note that the trigonometric variables input is expressed in '''radians''', not degrees
 +
 
 +
:By default, the format of calculation result on <code>[[GnEditText]]</code> is set to <code>0.00</code>.
 +
 
 +
:If the result needs to be formatted differently, check attribute <code>[[GnEditText#gn:decimalFormat|gn:s_decimalFormat]]</code> on <code>[[GnEditText]]</code>
  
 
;Action returns: void
 
;Action returns: void
Line 10: Line 16:
 
===Calculate result into target widget===
 
===Calculate result into target widget===
  
;<code>[gn:act_calculate]|[target,calculationFormula]</code>
+
:;<code>[gn:act_calculate]|[target,calculationFormula]</code>
  
{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
+
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
 
|-
 
|-
 
! scope="col" | Parameter
 
! scope="col" | Parameter
 
! scope="col" | Description
 
! scope="col" | Description
 
|-
 
|-
| [[target]]
+
| <code>[[target]]</code>
 
| [[target]] from where the while action is using value as expression parameter
 
| [[target]] from where the while action is using value as expression parameter
 
* Valid [[target|targets]]:
 
* Valid [[target|targets]]:
 
:*[[:Category:Widgets|widgets]]:
 
:*[[:Category:Widgets|widgets]]:
::*[[GnEditText]]
+
::*<code>[[GnEditText]]</code>
 
:*[[Variables|variables]]:
 
:*[[Variables|variables]]:
::*[[Datatypes#number|number]]
+
::*<code>[[Datatypes#number|number]]</code>
::*[[Datatypes#dateTime|dateTime]]
+
::*<code>[[Datatypes#dateTime|dateTime]]</code>
::*[[Datatypes#date|date]]
+
::*<code>[[Datatypes#date|date]]</code>
 
|-
 
|-
| calculationFormula
+
| <code>calculationFormula</code>
 
| represents formula to be calculated
 
| represents formula to be calculated
:WidgetId’s, String resources or ginstr app variables can be used to replace variable placeholders in the equation, i.e. <code>3*sin(@+id/widgetId)-2(@+variable/varId-2)</code>.
+
:WidgetId’s, String resources or ginstr app variables can be used to replace variable placeholders in the equation,
 +
::i.e. <code>3*sin(@+id/widgetId)-2(@+variable/varId-2)</code>.
 
:All values in actors should be numeric or they will be ignored in calculation
 
:All values in actors should be numeric or they will be ignored in calculation
 
:Actors that can be used as calculation variables:
 
:Actors that can be used as calculation variables:
Line 37: Line 44:
 
::*<code>[[GnDateTimePicker]]</code>
 
::*<code>[[GnDateTimePicker]]</code>
 
:*[[Variables|variables]]:
 
:*[[Variables|variables]]:
::*[[Datatypes#number|number]]
+
::*<code>[[Datatypes#number|number]]</code>
::*[[Datatypes#dateTime|dateTime]]
+
::*<code>[[Datatypes#dateTime|dateTime]]</code>
::*[[Datatypes#date|date]]
+
::*<code>[[Datatypes#date|date]]</code>
 
:*string resources
 
:*string resources
 
|-
 
|-
Line 45: Line 52:
  
 
====Example====
 
====Example====
<code>@variable/myResultVar</code> - [[target]] where the calculation result will be stored<br>
+
:<code>@variable/myResultVar</code> - [[target]] where the calculation result will be stored<br>
<code>@+id/widgetOne*@variable/calcVarOne</code> - calculation<br><br>
+
:<code>@+id/widgetOne*@variable/calcVarOne</code> - calculation formula<br>
<code>[gn:act_calculate]|[@variable/myResultVar,@+id/widgetOne*@variable/calcVarOne]</code>
+
:; ⤷ <code>[gn:act_calculate]|[@variable/myResultVar,@+id/widgetOne*@variable/calcVarOne]</code>
 
<hr>
 
<hr>

Revision as of 13:44, 12 July 2017

gn:act_calculate

Description
Action used to perform calculation operations on different actors and stores result in target.
If calculations with trigonometric functions give the wrong results, please note that the trigonometric variables input is expressed in radians, not degrees
By default, the format of calculation result on GnEditText is set to 0.00.
If the result needs to be formatted differently, check attribute gn:s_decimalFormat on GnEditText
Action returns
void

Action signatures

Calculate result into target widget

[gn:act_calculate]|[target,calculationFormula]
Parameter Description
target target from where the while action is using value as expression parameter
calculationFormula represents formula to be calculated
WidgetId’s, String resources or ginstr app variables can be used to replace variable placeholders in the equation,
i.e. 3*sin(@+id/widgetId)-2(@+variable/varId-2).
All values in actors should be numeric or they will be ignored in calculation
Actors that can be used as calculation variables:
  • string resources

Example

@variable/myResultVar - target where the calculation result will be stored
@+id/widgetOne*@variable/calcVarOne - calculation formula
[gn:act_calculate]|[@variable/myResultVar,@+id/widgetOne*@variable/calcVarOne]