Yaron 53 Posted November 12, 2018 (edited) I wrote a simple & elegant calculator for Android using Delphi Tokyo 10.2.3 and released the source code on GitHub:https://github.com/bLightZP/ElegantCalculator This sample demonstrates basic scalable Android UI, taking screen scale into account. I wrote a basic string math formula parser since I couldn't find anything free that would compile for Android. You can check out the compiled Elegant Calculator on the google play store:https://play.google.com/store/apps/details?id=com.inmatrix.ElegantCalculator Edited November 12, 2018 by Yaron 1 1 Share this post Link to post
jdredd 0 Posted November 12, 2018 With a few tweaks you can compile and install TArtFormula @ http://artsoft.tech/works.html Download @ http://artsoft.tech/download.html It works pretty well and supports quite a bit of things. Share this post Link to post
Yaron 53 Posted November 12, 2018 (edited) I actually reviewed two other formula parser, one was strictly windows and the other I thought I could convert, but after a few hours of work with it working perfectly under windows and having odd crashes under Android, I decided to just write something simple myself. Edited November 12, 2018 by Yaron Share this post Link to post
Andrea Magni 75 Posted November 13, 2018 An easy way to implement formulas is to rely on FireDAC expressions. It is very powerful (I built a simple spreadsheet-like application with very small effort!) Sincerely 1 Share this post Link to post
Rollo62 538 Posted November 13, 2018 Another good expression parser is the one from LiveBindings, explained by Daniele Teti. Not sure if that old XE2 sample still works, but it should give the basic idea. I use the expression engine of LiveBindings for calculations in my projects, usable in runtime. This is how I use it: uses System.Rtti , System.Bindings.EvalSys , System.Bindings.EvalProtocol , System.Bindings.Evaluator , System.Bindings.Methods ; function TTestCalculator.Evaluate(const AExpr: string) : Double; var LScope: IScope; LCompiledExpr: ICompiledBinding; LResult: TValue; begin Result := 0.0; try LScope := TNestedScope.Create(BasicOperators, BasicConstants); //add the registered methods LScope := TNestedScope.Create(LScope, TBindingMethodsFactory.GetMethodScope); LCompiledExpr := Compile(AExpr, LScope); LResult := LCompiledExpr.Evaluate(LScope, nil, nil).GetValue; if not LResult.IsEmpty then Result := LResult.AsExtended; finally LCompiledExpr := nil; LScope := nil; end; end; Share this post Link to post