0

Duplicate

I need a program in Delphi that get one variable equation from Edit1 such as "F(x)=4*X+2*log(x)+4*power(X,2)"
and get X value variable from Edit2 then show the result F(X) in Edit3. Please help me.

Thanks.

1

5 Answers 5

5

You can also check out JCL, which comes with an expression evaluator in the file JclExprEval.pas. It's free and open source.

Sign up to request clarification or add additional context in comments.

Comments

4

You probably need to have a look at this component - TbcParser.

https://www.mathparsers.com/formula-parser-for-delphi/

This component has source code included.

1 Comment

Thank you, replaced it with a working link
1

Have a look at

http://www.efg2.com/Lab/Library/Delphi/MathFunctions/Parsers.htm

Also, if you have JEDI and/or FastReport libraries installed you can use their parsers. We use TParser10 from http://cc.embarcadero.com/item/15974 which is one of the fastest available if not the fastest. It is freeware and work flawlessly up to D2007. I heard that it works also in D2009. Not tested yet though.

1 Comment

I'm the author of one of the packages on that list, Symbolic. Note that the URL there goes to the original (FPC) package. The Delphi package is at stack.nl/~marcov/symbolicdelphi.zip
0

If you want to write an own implementation and not use a ready to use library this will take you some time to do. Just search for "formula parser". I would start with a tokenizer and then build a parse tree from the tokens.

Comments

-1

It STRONGLY depdends on your decimal separator. Use StrToFloat or in newewr versions of Delphi - TryStrToFloat.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.