-
April 17th, 2012, 08:53 AM
#1
Existing code for String to Expression?
I would like to get hold of the code for a function that takes a string as input argument and returns a numerical value, either integer or double, according to the the expression represented by the string. For example the string may look like this:
Code:
"(256 * d3 + d4) * factor - offset"
then the function would calculate the value of
Code:
(256 * d[3] + d[4]) * factor - offset
where d is an integer array, factor and offset are double or int variables or constants. For my application the name for the array can be fixed to be "d", and the names for other variables and constants are known. The closest thing I could find on-line is this:
http://www.physicsforums.com/showpos...2&postcount=11
which only does literal integer calculations, no double, no variables or constants. Are there existing code that does what I need or do I have to write my own? Thanks!
-
April 17th, 2012, 09:18 AM
#2
Re: Existing code for String to Expression?
"Effective teaching is the essence of leadership..."
"There is no substitute for a carefully thought-out design."
If you have found this post to be useful, please Rate it.
-
April 17th, 2012, 09:27 AM
#3
Re: Existing code for String to Expression?
Originally Posted by mlgoff
Thanks for the quick reply but the link is for C#, not C++?
Edit: I found this:
http://www.codeproject.com/Articles/...essions-Parser
Thanks again!
Edit: and this:
http://code.google.com/p/muparserx/
Last edited by acppdummy; April 17th, 2012 at 11:02 AM.
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
|