LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Simple" Text Based Expression Evaluator?

I am writing some control logic code in LabView and have a
somewhat interesting question. I would like to provide users with the
capability of entering a "simple" text expression, and the "evaluator"
would respond either with a numeric or boolean value. Examples would be:

a+b
a*ln(b)
a+b>c

An even better "evaluator" capability would be to provide a
BASIC-like block of code:

IF a+b > c
THEN d=1
ELSE d=2
ENDIF

Better still:

IF ((a + b < c) AND (a < 5))
THEN d=1
ELSE d=2
ENDIF

Some of the requirements are:
1) Variable number of input and output variables
2) Some method of checking for a valid expression

Any help would be appreciated in this manner.

Thanks,
Andy

--
Andy Steinbach
stei0113@tc.umn.edu
0 Kudos
Message 1 of 5
(3,835 Views)
On 8 Jul 2000 18:34:55 GMT, stei0113@garnet.tc.umn.edu (Andrew J
Steinbach) wrote:

> I am writing some control logic code in LabView and have a
>somewhat interesting question. I would like to provide users with the
>capability of entering a "simple" text expression, and the "evaluator"
>would respond either with a numeric or boolean value. Examples would be:
>
>a+b
>a*ln(b)
>a+b>c

I have written a basic infix expression evaluator, and I could send
you a copy via email if you wish. Keep in mind that while it does
support constants, variables, and all of the standard operators, it it
still quite rudimentary.

I have not worked on this VI since I have begun using the GMath
Evaluate Formula String VI. It is certainly more robust than mine -
although I have not q
uite figured out how to manage a set of
user-defined variables (transparent to the VI), but that is another
issue all together.

> An even better "evaluator" capability would be to provide a
>BASIC-like block of code:
>
>IF a+b > c
> THEN d=1
> ELSE d=2
>ENDIF
>
> Better still:
>
>IF ((a + b < c) AND (a < 5))
> THEN d=1
> ELSE d=2
>ENDIF

I usually write my interpreters/compilers in a "real" language (i.e.
C/C++). 🙂

Reply via email if I can be of assistance.

Brett
0 Kudos
Message 2 of 5
(3,835 Views)
Hello,

we'd exactly the same problem and found a very suitable solution by
implementing the TCL-Shell (http://dev.ajubasolutions.com/) along with an
interface DLL/LIB in LabVIEW. It's only little work to get TCL running. TCL
is a very powerful bytecompiling interpreter with many many features (using
Tk-Extension also with a very powerful graphical interface 😉 and it's free.
The DLL is a simple interface to read and write TCL variables also from
LabVIEW without using TCL-Interpreter calls.

Jens-Achim

Andrew J Steinbach schrieb:

> I am writing some control logic code in LabView and have a
> somewhat interesting question. I would like to provide users with the
> capability of entering a "simple" text expression, and the "evaluator"
> would respond e
ither with a numeric or boolean value. Examples would be:
>
> a+b
> a*ln(b)
> a+b>c
>
> An even better "evaluator" capability would be to provide a
> BASIC-like block of code:
>
> IF a+b > c
> THEN d=1
> ELSE d=2
> ENDIF
>
> Better still:
>
> IF ((a + b < c) AND (a < 5))
> THEN d=1
> ELSE d=2
> ENDIF
>
> Some of the requirements are:
> 1) Variable number of input and output variables
> 2) Some method of checking for a valid expression
>
> Any help would be appreciated in this manner.
>
> Thanks,
> Andy
>
> --
> Andy Steinbach
> stei0113@tc.umn.edu

--
======================================
TECHNOGERMA Systems GmbH
Dipl.-Ing. Jens-Achim Kessel
Departement for Automation and Control
D-64291 Darmstadt, Roentgenstrasse 10a
phone: <++49> (6151) 99 58 7 - 74
fax: <++49> (6151) 99 58 7 - 62
e-mail: tgs.kessel@gmx.de
======================================
0 Kudos
Message 3 of 5
(3,835 Views)
I've read the answers in this thread, and I don't even think it's that
hard. I've done the same thing using LabVIEW code, and it's very easy.
If you have LV 5.1, look at the Mathematics->Formulas->Eval Formula
Node.VI in the diagram. This is similar to a formula node, except the
formula (as a string) is sent into the VI, parsed, and the answer comes
out. Basic if/then, boolean, logarithmic, and many other functions can
be used in the formula. I'll be more than happy to email you the VI so
you can look at it if you'd like.

Mark

In article <8k7s8f$pu4$1@laurel.tc.umn.edu>,
stei0113@garnet.tc.umn.edu (Andrew J Steinbach) wrote:
> I am writing some control logic code in LabView and have a
> somewhat interesting question. I would like to provide users
with the
> capability of entering a "simple" text expression, and the "evaluator"
> would respond either with a numeric or boolean value. Examples would
be:
>
> a+b
> a*ln(b)
> a+b>c
>
> An even better "evaluator" capability would be to provide a
> BASIC-like block of code:
>
> IF a+b > c
> THEN d=1
> ELSE d=2
> ENDIF
>
> Better still:
>
> IF ((a + b < c) AND (a < 5))
> THEN d=1
> ELSE d=2
> ENDIF
>
> Some of the requirements are:
> 1) Variable number of input and output variables
> 2) Some method of checking for a valid expression
>
> Any help would be appreciated in this manner.
>
> Thanks,
> Andy
>
> --
> Andy Steinbach
> stei0113@tc.umn.edu
>


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 4 of 5
(3,835 Views)
Andy,

The CalcExpress is powerful interpreter of expressions for LabVIEW. You
can find more information and download evaluation version on
http://calcexpress.mypage.org/
and
http://www.e-notebooks.com/products/calcexpress/

For processing of conditional expressions there is free addon for
CalcExpress. For more information you can contact with me by private
email.

Best regards,

Konstantin Shifershtain.
snow@fivt.kgtu.runnet.ru


In article <8k7s8f$pu4$1@laurel.tc.umn.edu>,
stei0113@garnet.tc.umn.edu (Andrew J Steinbach) wrote:
> I am writing some control logic code in LabView and have a
> somewhat interesting question. I would like to provide users with the
> capability of entering a "simple" text expression, and the "evaluator"
> would respond either with
a numeric or boolean value. Examples would
be:
>
> a+b
> a*ln(b)
> a+b>c
>
> An even better "evaluator" capability would be to provide a
> BASIC-like block of code:
>
> IF a+b > c
> THEN d=1
> ELSE d=2
> ENDIF
>
> Better still:
>
> IF ((a + b < c) AND (a < 5))
> THEN d=1
> ELSE d=2
> ENDIF
>
> Some of the requirements are:
> 1) Variable number of input and output variables
> 2) Some method of checking for a valid expression
>
> Any help would be appreciated in this manner.
>
> Thanks,
> Andy
>
> --
> Andy Steinbach
> stei0113@tc.umn.edu
>


Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 5 of 5
(3,833 Views)