Unreviewed Code - Simple Calculator
 Calculator
 *    solves simple mathematical expression
 *    remarks
 *	- available signs: "+", "-", "*", "/". brackets are not avail.;
 *	- unary minus is alowed;
 *	- sequence is "normal" (division, multip., substraction, addition)
 *	- numbers must be w/o thousand separators. decim. symbol: "."
 *    	- no other simbols are allovew
 *    params:
 *	- in  sExpr - expression (e.g. "-44+5-4--8")
 * 	- out dVal  - result. (? in case of error)
 *    return-value
 *	- in case of err, there will be returned description of err 
 *		folowed by symbols "2," in return-val 
 *		(e.g.: "2,Error description")
 *




Sample Code to demonstrate use:

/*
	test-calc.p
	
	i used theese function (calc and equa) to allow to user to define
	field validation on some my dynamic forms.
	
*/

/* some math formula */
def var sExpr as char.
sExpr = "$var1 + 0.5 * $var2".

/* set $var1 */
sExpr = replace (sExpr, "$var1", "102").
/* set $var2 */
sExpr = replace (sExpr, "$var2", "540").

def var d as dec.
run amlb-calc.p (sExpr, output d).
message "TEST CALC. result: " d " return-val" return-value.


[Download calc-v01.zip]
[Return to Unreviewed Code Section]
[Return to Main Download Page]

 
  [Home]     [Search]     [Download]     [FAQ]     [Mission]     [Contact Us]     [Legal Notice]     [Traduisent / Übersetzen / Traducen]     
Last modified on: Monday, 12-Jan-2004 15:44:28 UTC