Ah, WP, well, firstly, thanks for the wki article, I used it to get going, and I am going, so its good !
But the spirit of opensource says everything could be improved ! I was looking for another list of the trig functions supported, your wiki page, testing indicated and now the doc Bart sent me confirmed it does not do tan() - that surprised me. I'd like to know if it can do degrees instead of radians and so on.
And if I was being really picky (and I can be) I think the wiki page could do with a simple stand alone example. Your example code is mixed a bit with snippits from the package as you explain how it works internally. A first time reader could be forgiven for thinking the package is a bit harder to use than it really is.
Studying your article, I came up with this -
function TEditBoxForm.DoCalculate(CalcStr : string) : string;
var
FParser: TFPExpressionParser;
parserResult: TFPExpressionResult;
begin
result := '';
FParser := TFPExpressionParser.Create(nil);
try
try
FParser.Builtins := [bcMath];
FParser.Expression := CalcStr;
parserResult := FParser.Evaluate;
case parserResult.ResultType of
rtInteger : result := inttostr(parserResult.ResInteger);
rtFloat : result := floattostr(parserResult.ResFloat);
end;
finally
FParser.Free;
end;
except on E: EExprParser do showmessage(E.Message);
end;
end;
If you don't mind, I'll add it to your article ?
edit : Oh, wish I could learn to read properly, you even have an example of how to add tan() to it. sigh .....
David