---------------------------------------- Advanced Calculator (C) v2.0 for Delphi 3,4 Copyright 1999 by George Barbakadze All rights reserved http://adcalc/homepage.com giga@fnmail.com ---------------------------------------- GENERAL INFORMATION ------------------- A fast expression evaluator which can be used to evaluate mathematical expressions at run time, by the following possibilities: 1) Arithmetical operations for EXTENDED type expresions: + : Addition - : Substraction * : Multiplication / : Division ^ : Power ( : Open parenthesis ) : Close parenthesis 2) Functions operating EXTENDED or REAL type expressions: Frac, Int, Round, Exp, Log, Ln, Sin, Cos, ArcSin, ArcCos, Sinh, Cosh, ArcSinh, ArcCosh, Tan, CoTan, ArcTan, ArcTanh, Tanh, Sqr, Sqrt, Abs Ranges of these functions in a full likeness with Delphi same name functions. 3) Functions operating BOOLEAN type expressions: Function IF(logical_test, value_if_true, value_if_false) Logical_test - is any value or expression that can be evaluated to TRUE or FALSE. Value_if_true - is the value or expression that is returned if logical_test is TRUE. Value_if_false - is the value or expression that is returned if logical_test is FALSE. Function NOT(logical_value) returns opposite BOOLEAN type significance 4) Comparison of EXTENDED type values returning BOOLEAN type significance > : greater < : less = : equally >= : greater or equally <= : less or equally <> : greater or less 5) Operators of BOOLEAN type expressions (AND, OR): Logical_Value AND logical_Value OR logical_Value... These operators of smaller priority, than sign of comparison. 6) Unlimited number of user-defined EXTENDED and BOOLEAN type variables and functions. Example: procedure TForm1.AdCalc1GetExtendedVar(Sender: TObject; VarName: String; var Found: Boolean; var Value: Extended); begin if VarName = LowerCase('MyExtendedVar') then begin Found := true; Value := 100; end; end; procedure TForm1.FormCreate(Sender: TObject); begin AdCalc1.DefExtendedFunct('Max',[expExtended,expExtended]); ... end; ... procedure TForm1.AdCalc1GetExtendedFunct(Sender: TObject; FunctName: String; var Found: Boolean; var Value: Extended); begin if FunctName = LowerCase('Max') then with AdCalc1 do begin Found:=true; if extended(GetParam(1)^) > extended(GetParam(2)^) then Value := extended(GetParam(1)^) else Value := extended(GetParam(2)^); end; end; 7) Complete error handling support, including returning the ERROR CODE, DESCRIPTION OF ERROR and POSITION in the line where an error ocurred. The full list of errors is: 1. Line is Long /Maximum length of identifier is 64 character/ 2. Numerical expression expected 3. Boolean expression expected 4. Arithmetical sign expected 5. Comparison sign expected 6. "AND" or "OR" expected 7. "(" expected 8. ")" expected 9. "," expected 10. Division by zero Example: procedure TForm1.AdCalc1Error(Sender: TObject; ErrorCode, ErrorPosition: Word; ErrorStr: String); begin Label1.Caption := 'Error ' + IntToStr(ErrorCode) + ' - ' + ErrorStr; Edit1.SelStart := ErrorPosition; end; INSTALLATION ------------ To use this component in your applications: Copy the following files into a directory of your choice: 1. AdCReg.pas 2. AdCReg.dcr 3. AdCalc.dcu Then: Component / Install Component / Browse / AdCReg.pas / Ok / Compile