====== Calculate ====== The Calculate element can arithmetically manipulate [[eyes:flowcontrol:variable|Variables]], whereby the I/O remains unmodified. ===== Usage ===== {{ :eyes:flowcontrol:calcprop.png?nolink|}} This Flow Control element can apply standard arithmetic (+,-,*,/) onto a Variable. Furthermore, the modulo (%) and exponentiation (^) methods are implemented in Lua 5.1. To edit the formula fill in the Formula field in the Properties. Please note that Variables are called with cow.VariableName.\\ ** Computation with a constant ** \\ cow.VariableName = cow.VariableName + ( any standard arithmetic symbol ) constant \\ ** Computation with a other Cow Variable ** \\ cow.VariableName = cow.VariableName + ( any standard arithmetic symbol ) cow.VariableName \\ Recall that a calculation of a Variable of type decimal and a Variable of type integer returns a Variable of type decimal. \\ \\ \\ ===== Example ==== {{:eyes:flowcontrol:examplecalc.png?nolink&650 |}} **Properties Window** |< 100% 2% 40% >| ^ ^ ^ |{{:eyes:flowcontrol:a.png?nolink&20|}}|{{:eyes:flowcontrol:boxinteger.png?nolink&600|}}|The [[eyes:flowcontrol:variable|]] factor is passed to the logic [[eyes:logics:boxmanipulation|]]. Factor is used as the coarse factor for the selected processor Coarse.| |{{:eyes:flowcontrol:b.png?nolink&20|}}|{{:eyes:flowcontrol:varinteger.png?nolink&600|}}|Here the [[eyes:flowcontrol:variable|]] called factor is of type integer with default value two. To see how to set up and use a [[eyes:flowcontrol:variable|]] follow the link.| |{{:eyes:flowcontrol:c.png?nolink&20|}}|{{:eyes:flowcontrol:groupcalc.png?nolink&600|}}|After clicking into the grey part of the element [[eyes:flowcontrol:group|]] the properties window displays the current value of the [[eyes:flowcontrol:variable|]] factor.| |{{:eyes:flowcontrol:d.png?nolink&20|}}|{{:eyes:flowcontrol:examplecalcprop.png?nolink&600|}}|The Calculate element displays the computation. Here the sum of the [[eyes:flowcontrol:variable|]] factor and one is written back to the [[eyes:flowcontrol:variable|]] factor.| ===== Parameters and I/O ===== |< 100% 30% >| ^ Input ^ Description ^ | FirstInput | Input is passed along and triggers Calculate| |< 100% 30% >| ^ Output ^ Description ^ | FirstOutput | Output which is unmodified | ===== Concept ===== [[https://www.lua.org/pil/3.1.html|Arithmetic Operators in Lua]]