|
I am working on a port of UNIX Xspread to windows. I am attempting to integrate this code into my MFC application, however, I cannot get it to compile. Below is the code snippet intended to get the result:
CString Expression;
//Call the math parser, get the function result and set the cell value to the result
CFunction<long double="">* bob = CFunction<long double="">::Parse(m_strText);
Expression = bob->GetName();
Note: when I post this message to this site, the template prefix argument keeps disappearing (strange). CFunction has a template argument of long double (so does the scope for the call to Parse). This is OK in my application.
Here is the errors:
C:\My Documents\MyProjects\Xspread32\xspread32\Grid_src\GridCell.cpp(212) : error C2065: 'CFunction' : undeclared identifier
C:\My Documents\MyProjects\Xspread32\xspread32\Grid_src\GridCell.cpp(212) : error C2062: type 'long double' unexpected
C:\My Documents\MyProjects\Xspread32\xspread32\Grid_src\GridCell.cpp(212) : error C2039: 'Parse' : is not a member of '`global namespace''
C:\My Documents\MyProjects\Xspread32\xspread32\Grid_src\GridCell.cpp(213) : error C2065: 'bob' : undeclared identifier
C:\My Documents\MyProjects\Xspread32\xspread32\Grid_src\GridCell.cpp(213) : error C2227: left of '->GetName' must point to class/struct/union
I did include the header files, and the IDE does display that the object "func" is a CFunction object (i.e. when you hover the cursor over the object name in MVC++ 6). I just can't make a connnection between my code and this math parser. I downloaded the command line code and it compiles with no problems. I created a new MFC project and tried to integrate the parser in the same manner as the console code that worked & I got the same errors. I am relatively new to MFC (not new to C++ however) and I could use any help I can get.
Luke
|
|
|
|
|
I figured it out. Had the #includes for the math parser's headers over #include stdafx.h.
|
|
|
|
|
Hello,
I did a version of this source without any MS dependecies... If someone is interested, please mail me...
|
|
|
|
|
Hello,
I'm looking for a function parser and I would be very interested by your source without MS dependencies because i must run my application on unix platform.
Could you send me a copy of your version ?
Thanks,
Jean-Luc
|
|
|
|
|
|
Thank you for the code.
I would suggest you remove the .ncb file from your package, that would reduce dramatically the download size...
|
|
|
|
|
|
|
Hi There,
I just found the code. I have not tested it yet but it seems to be the Function parser is a good parser. My question is that the parser can pass following expression:
f(x)=2*x+5
I guess it should be a big problem to pass following more general expression
f(x)=a*x+b;
Thanks for any advice!
Jie Luo
|
|
|
|
|
Don't argue you guys! Remember - world peace
And now let's reach the another abstraction level. One definitely doesn't need such a complicated machine to perform parsing. All of you should check the free code I found at http://www.students.tut.fi/~warp/FunctionParser/. It's truly amazing how simple things work best.
Regards,
BB
P.S. Andreas, for God's sake - write comments in English!
|
|
|
|
|
1st, thanks to Andreas of sharing his code.
2nd, B.Starks probably right that W.Dean does not know as much as he loud speaks. But he, & not concern to his programming abilities, right in one point: If you, Andreas, post an article here - make it readable. Dont expect us to read German inline documantation and write more that two sentences that say only "it will be too complex to describe".
Amit Gefen.
Project Lead - Software Engineer
Dusseldorf, Germany.
|
|
|
|
|
I would not expect a detailed explanation of the implementation. But it would be nice to know what it does exactly. Ie what operators and functions does it support? What operator precedence (if any) is used? Does it only use floating point types? Is the syntax C-like?
For example, can you do things like:
(x < 1) ? x : x*x
I am looking for a parser, but I won't try this as I don't think it is what I am looking for. I need something that evaluates one-off expressions (using boolean, int and floating point types) containing any number of "variables" for which I can provide the value.
Andrew Phillips
andrew @ expertcomsoft.com
|
|
|
|
|
I have had good success with using this parser. There was far too much work to develop it to think
that the problems discussed previously are really insurmountable
Look at B. Starks comments, they are useful.
Two issues though, the first is that if you use US setting, you MUST find and remove or change
the line which substitutes , for .
in FktParse.h--CMathString::Replace_All(str, _T(","), _T("."));
If you don't, there is a use of strtod() that will think that the , is a delimiter
and you'll only get the intiger portion translated.
Second, there will be memory leaks if you don't delete(fkt) after you are done with it.
Just an amateur.
|
|
|
|
|
|
To Dean Wyant,
I nearly didn't bother trying FunctionParser due to your scathing review. However, I'm glad I recognized that Dean simply doesn't know very much and talks too much. I went ahead and tried FunctionParser and found it to be good.
The issue with the '.' changed to ',' as almost all experienced programmers know, is due to Locale settings (the code was written in Germany, you are in the U.S.). Simply comment out the line that replaces the '.' with ','.
Next the issue you have with it not being able to parse (x*3.5) / (x*x) is due to the fact that the author wrote a quick and dirty using std::cin which everyone knows will stall on the ' ' in front of the '/'. This isn't a problem if you simply don't use std::cin for input from the user. You can't blame the author for this either because he was simply trying to provide a demonstration app quickly, however he could clear this up by not using cin.
I find the Parser to be a good one and thank the author for sharing it, and gladly accept any problems it may have. To Dean Wyant I suggest that you should evaluate your own programming abilities before railing on someone for providing great code that is simply above your abilities to understand.
Sincerely,
B. Starks
b_starks@hotmail.com
|
|
|
|
|
I'm sorry. No one bothered to reply to my message, including you. You created a new message so I was never informed of your reply. Just like an idiot... flame away clown boy..... Perhaps my programming standards are higher than yours.
My opinion remains = There is no support for the issues in using this parser - even you would not directly reply to a posted message here. It does not handle parens properly, decimals, and several other issues. You are correct about the locale and partially correct about the std:cin. The part about me was way off base.
As I stated in my message - my message was not meant to be mean or degrading. Obviously, it came across to you as "railing" the author.
Yes, I was ignorant for not noticing the , problem was a locale issue. And, my message could have been written as questions instead of statements about how it did not work. I am glad that some people are willing to share anything at all. My bad.
Hmm, what has B. Stark shared?
Perhaps this code is wonderful? How about an update from you or the author or anyone to show how wonderful it is. I am sure that a decent test interface that will accept string input properly, some bug fixes, and a little documentation would be very helpful. I could care less, I am too busy making money using my programming skills to mess with this code.
|
|
|
|
|
I have a better parser. You want it? email: stocklab@21cn.com
|
|
|
|
|
this is what I want, if your have chance, Please sent better code to me
thank a lot
Ping he
thank a lot
|
|
|
|
|
the above email of stocklab is no longer valid as of today
Peter
|
|
|
|
|
When the equation 8.31451*x is entered the parser ignores the decimal places. So if x=2 then the result is 16.
|
|
|
|
|
The author did not respond to my e-mail so I will place my comments here.
The parser changes '.' to ',' instead of vice-versa.
Spaces are not supported and the simple solution of removing them is not coded.
Some apprently syntatically correct expressions do not parse properly due to other bugs.
Parenthesis do not work correctly since the code blindly removes leading and trailing parens that might not match.
So, the code fails to "parse and evaluate standard mathematical functions"
Overall, the code is interesting but it is very limited in its usefulness. The code that parses the expression is difficult for me to understand and follow. Maybe I am just unaware of the logic or algorithm used? I find it hard to understand how this article that has no supporting text on usage, theory, approach, purpose, etc. and contains code with obvious bugs could rate such high marks from so many users?
Have I misunderstood something? How is this code useful? I am not trying to be rude, mean or degrading. Please explain why I am wrong.
Has someone actually fixed this so that it will parse and evaluate standard mathematical functions beyond single simple operations such as f(x) = x+2 to parse expressions such as f(x) = (x * 3.5)/(x * x)? I fixed several bugs, but then I gave up because I did not have confidence in the logic used for the parse function.
|
|
|
|
|
I'm interested in evaluating this class in more detail, but was wondering if anyone could translate the German language comments to English.
|
|
|
|
|
Is the following possible:
F(x,y)=....
or like
fkt->Execute(5,4); ??
|
|
|
|