This component supports algabraic functions in the application templates.
The supported functions are: "+", "-", "*", "/", and "%".
The component allows the template developer to process 2 parameters, integers 'arg1' and 'arg2', using these algabraic operators via an operator variable called 'operator'.
The result of the component is held in a variable, which is defined in the template using 'var'. It can be called whatever you prefer it to be called, but it has to be printed in the template for the result to show.
For a complete list of the supported functions, please see the Supported Attributes table below.
The following example will add the 2 parameters, and displays the answer: 7
<fm:Math arg1="3" arg2="4" operator="+" var="AdditionAnswer" >
Answer: {$AdditionAnswer}
</fm:Math>
NOTE: The paramaters arg1, arg2 and operator are required, otherwise an error will result. They are to be passed as arguments inside the fm:Math tags.
Name | Required | Default | Description |
---|---|---|---|
% | Optional | This will calculate the remainder of argument 1 being devided by argument 2 | |
* | Optional | This will multiply 2 arguments | |
+ | Optional | This will add 2 arguments | |
- | Optional | This will subtract the 2nd argument from the 1st | |
/ | Optional | This will divide argument 1 by argument 2 | |
arg1 | Required | N/A | First argument of the operation |
arg2 | Required | N/A | Second argument of the operation |
operator | Required | An Error will result if all 3 arguments are not provided | The mathematical operator to be used for the 2 arguments (numbers). Valid values are "+", "-", "*", "/", and "%". |
rand | Optional | This will display a random number between argument 1 and argument 2 | |
var | Optional | N/A | Populate this var with the result of the operation, otherwise the result will be displayed |
NOTE: The paramaters arg1, arg2 and operator are required, otherwise an error will result. They are to be passed as arguments inside the fm:Math tags.
This component defines no template variables.
This component does not output variables, just numbers.
'*' multiplies 2 integers The following code will multiply 3 * 4 to give 12.
<fm:Math arg1="3" arg2="4" operator="*" var="MultiplicationAnswer" >
Answer: {$MultiplicationAnswer}
</fm:Math>
'%' calculates the remainder for dividing arg1 by arg2. The following code will calculate the remainder of 5 divided by 4, which is 1.
<fm:Math arg1="5" arg2="4" operator="%" var="ModulusAnswer" >
Answer: {$ModulusAnswer}
</fm:Math>
The following example calculates the decimal and percentage for dividing arg1 by arg2. The result wil be: Initial Answer: 0.428571428571 Percentage: 42.8571428571
Initial Answer: {$PercentageAnswer1}
Percentage: {$PercentageAnswer2}