Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Formula Parser for Delphi

645 views
Skip to first unread message

Adam H.

unread,
Sep 23, 2007, 7:54:32 PM9/23/07
to
Hi,

I'm looking for a formula parser in delphi, that can handle conditions (ie,
IF statements).

I can find a number of parsers that can handle basic maths (ie, 2+2, 2*2,
2/2, 2-2), etc, but what I need is something that can also handle if (or
iif) statements.

ie: iif(2>1, 1+1, 2*2)

(What I would like to be able to do in my application is have a table called
formula's. where the user can store certain formula's, and the application
make adjustments to calculations based on those formulas. In order to do
this, I need the user to have the ability to apply constraints/conditions
such as if a value is greather than, less than or equal to, and then the two
resulting values, etc).

Can anyone help me please?

Thanks & Regards

Adam.


Björn Schreiber

unread,
Sep 24, 2007, 3:12:22 AM9/24/07
to
Adam H. wrote:

> I'm looking for a formula parser in delphi, that can handle conditions (ie,
> IF statements).

http://www.remobjects.com/page.asp?id={9A30A672-62C8-4131-BA89-EEBBE7E302E6}

Does it fits your needs?


Greetings,
Björn
--
Björn Schreiber, DRIGUS GmbH
new...@drigus.de
Bei Email NOSPAM in den Betreff aufnehmen.
Put NOSPAM in subject to reach me by email.

Adam H.

unread,
Sep 24, 2007, 7:32:05 AM9/24/07
to
Hi Björn,

>> I'm looking for a formula parser in delphi, that can handle conditions
>> (ie, IF statements).
>
> http://www.remobjects.com/page.asp?id={9A30A672-62C8-4131-BA89-EEBBE7E302E6}
>
> Does it fits your needs?

Thanks for your reply, although I'm not sure that it's exactily what I'm
looking for. If I understand this set of components correctly, these are
more script parsers (similar to Jedi's TJvTranslator component). What I'm
chasing is more a expression calculator that has the ability to perform if
(or iif) statements - similar to that in Excel (although I don't have the
need to parse variables to it - but I'm assuming if something exists, that
would be the context that it work work with).

But thanks for your post anyway.

Cheers

Adam.


Roy Lambert

unread,
Sep 24, 2007, 9:00:35 AM9/24/07
to
Adam


What about Scripter Studio from http://www.tmssoftware.com/

Roy Lambert

Mike Shkolnik

unread,
Sep 24, 2007, 3:31:37 PM9/24/07
to
Adam,

you may use the parser which included in SMImport:
http://www.scalabium.com/smi

Check the sample in DEMOS\Evaluator directory. There is a sample both for
visual expression dialog (where end-user can edit the formula) and for
evaluator (TSMIParser class)
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshk...@scalabium.com

"Adam H." <ahai...@rREMOVEMEspamSTOPPER.jvxp.com> wrote in message
news:46f6fcb7$1...@newsgroups.borland.com...

Adam H.

unread,
Sep 24, 2007, 6:53:49 PM9/24/07
to
Hi Roy,

> What about Scripter Studio from http://www.tmssoftware.com/

Thanks for the suggestion, but once again, it seems more like a pascal
scripter rather than just an expression evaluator.

I think Mike has what I'm looking for though!

Cheers

Adam


Adam H.

unread,
Sep 24, 2007, 6:54:30 PM9/24/07
to
Hi Mike,

> you may use the parser which included in SMImport:
> http://www.scalabium.com/smi
>
> Check the sample in DEMOS\Evaluator directory. There is a sample both for
> visual expression dialog (where end-user can edit the formula) and for
> evaluator (TSMIParser class)

Perfect! Thanks heaps. I've already got SMImport and SMExport, and had no
idea this little gem was already sitting here in Delphi ready to be used!
:-)

It allows for exactily what I'm after!

Cheers

Adam.


rbwinston

unread,
Sep 24, 2007, 9:11:10 PM9/24/07
to
I have posted one I wrote in borland.public.attachments. The Test
directory has a unit test. the PasDoc directory has documentation. An
earlier version of this component was used in GoPhast. The program
with source code can be downloaded from
http://water.usgs.gov/nrp/gwsoftware/GoPhast/GoPhast.html

It can handle real numbers, integers, booleans and strings. The unit
test shows how to use it.

sup...@bestcode.com

unread,
Jan 12, 2014, 8:51:08 PM1/12/14
to
TbcParser (http://www.mathparsers.com/formula-parser-for-delphi/) can do IF(condition, useThisIfTrue, useThisIfFalse) for example:

IF(x<>0, y/x, y)

There are formula parsers for many languages at http://www.mathparsers.com/ C++, Java, Objective C, C#, Delphi, COM (vb 6 anyone?) are all covered by a suite of math parser libraries. Most of them support strictly mathematical formulas in the expression to parse. C# version supports strings in the expression as well. Users can define their own variables and user defined functions to use in the expressions.
0 new messages