Calc Test Page: Difference between revisions

From Distillers Wiki
Jump to navigation Jump to search
No edit summary
(updated with instructions in comments.)
Line 7: Line 7:
<!--
<!--


  Testing to see if "expr" can use variables. It should. I think the issue is that the Vars aren't being defined properly so the equation fails.
#vardefine creates the variable & gives it a value.
UJ - It looks like the "Variables" module needs to be loaded. See : https://www.mediawiki.org/wiki/Extension:Variables Installation
#var allows you to use it. you need to use it like {{#var:X}}
y
{{#var:X}} by itself will print the value of the var
SMY - I enabled the "variables" extension - UJ
To do a calculation you need to use {{#expr:equation}} - this will also print the value of the expression.


-->
-->
<br>
<br>
{{#vardefine:X|2}}
{{#vardefine:X|2}}
Line 18: Line 20:
{{#vardefine:Y|3}}
{{#vardefine:Y|3}}
<br>
<br>
<br>'''Using Variables test calc3'''  {{#expr:{{X}}*{{Y}}}}
<br>'''Using Variables test calc'''  {{#expr:{{#var:X}}*{{#var:Y}}}}
<br>'''Using Variables test calc4'''  {{#expr:{{#var:X}}*{{#var:Y}}}}
 
<br>'''Using Variables test calc5'''  {{#expr:#var:X*#var:Y}}
<br>
<br>


{{#vardefine:a|3 }}
{{#vardefine:a|3 }}
{{#vardefine:b|9 }}
{{#vardefine:b|9 }}xxx
{{#var:x|{{#expr:2*{{#var:a}}+{{#var:b}}}}}}
{{#vardefine:x|{{#expr:2*{{#var:a}}+{{#var:b}}}}}}<br>xxx
 
{{#var:x}}
<!-- Random php code test -->
<!-- Random php code test -->
<br>
<br>

Revision as of 15:49, 17 November 2022

Sample code test Calc e^43 = 4.7278394682294E+18

Simple Math test Calc2 2*3 = 6







Using Variables test calc 6



xxx
xxx 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