Re: Storing Formulas - Database

Tech-Archive recommends: Fix windows errors by optimizing your registry




"Brian P. Hammer" <BrianHammer@xxxxxxxxxxxxxxxx> wrote in message
news:%23OyFyizPGHA.3272@xxxxxxxxxxxxxxxxxxxxxxx

All - I have a project that has a bunch of formulas. I would like to
store each of the formulas in a SQL and then load them and have my app
execute it. The problem I see is that a Dataset would return the formula
as a string and not as a result. Anyone have an idea on how I could
accomplish this?

Example: If I wanted to store ((5+15)-9)*10 in SQL. I want to display the
answer 111 in a text box and not ((5+15)-9)*10

What you need is an EXEC function - a function which can treat a string as a
line of code and compute it. You could write your own interpreter but you
will not enjoy that - see "The dragon book" (Compilers: Principles,
Techniques and Tools by Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman) if you
don't believe me. You may find it easier to use an Excel spread*** to do
this. Another approach is a parser subroutine - see
http://www.codeproject.com/cpp/FastMathParser.asp which might work OK.



.


Quantcast