Jump to content

Need a fomula parser VI


Recommended Posts

Has anyone written a VI that will take a simple math formula in a string like:

1+2-3

4+(5*3)

3-(4+5)

And return the computed result?

I know that NI provides this function in the Eval Formula String.vi in the Gmath library but that is the problem. They put this in a lvlib file. I am trying to build an application with the OpenG builder that includes this function and discovered that the OpenG builder cannot deal with lvlib files properly. Since my application is dependent on the namespace feature of the OpenG builder, my only option is to reinvent this math function myself outside of a lvlib.

I have tried to find a way to extract this from the lvlib with no luck.

So, can anyone help me not have to reinvent this wheel?

Thanks for any help you can offer,

-John

Link to comment

QUOTE(jlokanis @ Aug 29 2007, 12:43 PM)

Well if you have a LabVIEW version before 8.0 somewhere you can copy the stuff from there. There was no lvlib before 8.0.

Alternatingly I wrote long ago a library that works similar to the NI Eval Formula function but is implemented a bit differently dividing the evaluation cleanly into a parser that creates UPN stack intermediate code and an evaluater that operates on that intermediate code. I needed that for speedy calculations where user entered formules would be needed but they didn't change all the time, so parsing the formula once and then evaluating it over and over again had some serious perfomance advantages. The parsing is not trivial but a lot more streamlined than the NI code and the entire thing is also faster.

It hasn't been updated for several years but worked fine for what I needed it.

LabVIEW 5.0 ExprEval.zip

Rolf Kalbermatter

Link to comment

QUOTE(jlokanis @ Aug 29 2007, 12:43 PM)

I am trying to build an application with the OpenG builder that includes this function and discovered that the OpenG builder cannot deal with lvlib files properly. Since my application is dependent on the namespace feature of the OpenG builder, my only option is to reinvent this math function myself outside of a lvlib.[/font][/size]

I'm using the built in formula parser with the OpenG Builder inside of an LLB with name mangling (adding a prefix specifically) and its working fine. I'm using builder beta 7 in LabView 8.2. I did have trouble with beta 8 when I beta tested it, so I switched back to beta 7. If I remember right, the OpenG Builder beta 7 doesn't actually name mangle files inside a lvlib, but my application was ok with that.

Link to comment
  • 10 years later...

Not sure if openG builder and lvlib is still a problem (I don't use openG builder), but I do know that including gmath library increases application builder's executable build time by about 14 minutes (LV2015).

On 8/30/2007 at 3:04 PM, John Lokanis said:

So, can anyone help me not have to reinvent this wheel?

I was about to reinvent as well but then I came across muParser: http://beltoforion.de/article.php?a=muparser

LabVIEW API here: 

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.