-
March 3rd, 2012, 03:34 PM
#1
How can an application execute a mathematical formula edited in an Edit
Hello every one
I am so tired about this problem. Please can someone help me.
In my application I need perform a procedure which can read a mathematical formula form an Edit and execute it. The problem is how can I convert this string to a real function
Thank you
-
March 3rd, 2012, 04:33 PM
#2
Re: How can an application execute a mathematical formula edited in an Edit
Originally Posted by nunca
In my application I need perform a procedure which can read a mathematical formula form an Edit and execute it. The problem is how can I convert this string to a real function
You cannot convert it to a C++ function, because those only exist at compile time, not in run-time.
What you can do is implement a parser that can interpret the formula and either calculate the result directly or produce a bunch of objects that can calculate the result. Read up on recursive descent parsers to learn more. You could also try to use a library such as Boost Spirit to build the parser.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
-
March 5th, 2012, 05:15 PM
#3
Re: How can an application execute a mathematical formula edited in an Edit
For parsing a string in an attempt to interpret it as a function, the following article might give you some ideas: "Symbolic Differentiation" By Hatem Mostafa at http://www.codeproject.com/Articles/...ifferentiation
It's not easy to do.
Mike
-
March 6th, 2012, 03:21 PM
#4
Re: How can an application execute a mathematical formula edited in an Edit
Check this out.
http://www.codeproject.com/Articles/...essions-Parser
I've used it and it is quite useful for the purpose that you have stated.
mpliam
-
March 6th, 2012, 04:47 PM
#5
Re: How can an application execute a mathematical formula edited in an Edit
@Mike, nice find.
@OP, here is another one at that site: "An extensible math expression parser with plug-ins" by Mathieu Jacques at http://www.codeproject.com/Articles/...-with-plug-ins
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|