Calc Test Page: Difference between revisions
No edit summary |
(More documentation) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
< | <nowiki>#vardefine creates the variable & gives it a value. | ||
</nowiki><br><nowiki> #var allows you to use it. you need to use it like {{#var:X}} | |||
</nowiki><br><nowiki> {{#var:X}} by itself will print the value of the var | |||
</nowiki><br><nowiki> To do a calculation you need to use {{#expr:equation}} - this will also print the value of the expression. | |||
</nowiki><br><nowiki> Check the source of the page for examples. | |||
</nowiki> <br> | |||
<br> | <br> | ||
{{#vardefine:X|2}} | {{#vardefine:X|2}} | ||
Line 18: | Line 19: | ||
{{#vardefine:Y|3}} | {{#vardefine:Y|3}} | ||
<br> | <br> | ||
<br>'''Using Variables test | <br>'''Using Variables test calc''' {{#expr:{{#var:X}}*{{#var:Y}}}} | ||
<br> | <br> | ||
{{#vardefine:a|3 }} | {{#vardefine:a|3 }} | ||
{{#vardefine:b|9 }} | {{#vardefine:b|9 }} | ||
{{# | {{#vardefine:x|{{#expr:2*{{#var:a}}+{{#var:b}}}}}}<br> | ||
{{#var:x}} | |||
<!-- Random php code test --> | <!-- Random php code test --> | ||
<br> | <br> |
Latest revision as of 16:04, 17 November 2022
Sample code test Calc e^43 = 4.7278394682294E+18
Simple Math test Calc2 2*3 = 6
#vardefine creates the variable & gives it a value.
#var allows you to use it. you need to use it like {{#var:X}}
{{#var:X}} by itself will print the value of the var
To do a calculation you need to use {{#expr:equation}} - this will also print the value of the expression.
Check the source of the page for examples.
Using Variables test calc 6
15
This is PHP code for a calculator
<?php if(isset($_POST['sub'])){ $num1=$_POST['n1']; $num2=$_POST['n2']; $oprnd=$_POST['sub']; if($oprnd=="+") $ans=$num1+$num2; else if($oprnd=="-") $ans=$num1-$num2; else if($oprnd=="x") $ans=$num1*$num2; else if($oprnd=="/") $ans=$num1/$num2; }?>
Links to useful pages
https://t4tutorials.com/simple-calculator-using-php/
https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions
https://www.mediawiki.org/wiki/Extension:Variables