LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I am looking for an boolean and numeric expression evaluator. I want to be able to compare (>,=, <, or, not, and, nand, etc)and evaluate boolean/numeric expression.

I am looking for an boolean and numeric expression evaluator. I want to be able to compare (>,=, <, or, not, and, nand, etc)and evaluate boolean/numeric expression. Does anyone know if there is any code samples anywhere. If anyone has any input, I would greately appreciate it.
0 Kudos
Message 1 of 8
(4,054 Views)
Hi, Yuliya.
Do you need to use bitwise operations?
If so you can easily wire numbers to boolean operators. But remember that in this case you will work with bits, not the numbers.
For example in binary format
not(101011) will return 010100. This can be done by wiring of the number 43(101011b) to the boolean operator NOT.

In any case read the help file for logic operations. There is written how to use them as bitwise functions in the case of numbers.

Good luck.

Oleg Chutko.
Message 2 of 8
(4,054 Views)
No, I don't have to use bits. It is purely numeric and logical. I need to be able to evaluate something of the form "-(-60+4)>5 and (9=!7 or --8>9)", which shoud give out "True" as a result. So, it is almost like a calculator but it has to use comparison and logical operators as well as regular mathimatical binary operators.

Yuliya
0 Kudos
Message 3 of 8
(4,054 Views)
Hi, again.
OK, you just need to use boolean and comparision functions. What is the problem?
In the case of (9=!7 or --8>9) you have to use "Not equal?" and "Greater?" functions from "Functions->Comparison" palette which return boolean results. Then you have to perform "OR" operation from Boolean palette.

May be it will be easier to do all this logics in Formula Node. Try there.

Good luck.

Oleg Chutko.
0 Kudos
Message 4 of 8
(4,054 Views)
The problem is that I have to enter a string of that type (any random string), and the program should go and calculate the result for the whole stirng, by looking at which parts to calculate first (figuring out precedence), second, etc. This is like a calculator, you don't know what the user is going to enter next, so I can't just use the boolean palatte. I could use it if the equation was always of the form "a 'operator' b", where the operator is any logic or comparison operator. But that is not what I am trying to accomplish.
Can you do logic in the formula node? I think it only allows numeric values for inputs and outputs, it doesn't let you enter in and output booleans and stuff..does it?
Thanks,
Yuliya
0 Kudos
Message 5 of 8
(4,054 Views)
Functions -> Mathematics -> Formula -> Eval Formula Node.vi. Just like a formula node, but the formula can be entered on the fron panel / run-time...

Mads
0 Kudos
Message 6 of 8
(4,054 Views)
Could you give me an example of the formula that you would feed to the Eval Formula Node.vi for something like this: ""-(-60+4)>5 and (9=!7 or --8>9)"? I am not sure that it would take something like that, but I don't use formula nodes too often, so I don't know.
0 Kudos
Message 7 of 8
(4,054 Views)
It's unfortunately not the complete solution..to get closer read the following:

http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000B54A0000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=boolean+and+numeric+expression+evaluator&USEARCHCONTEXT_QUESTION_S=0
0 Kudos
Message 8 of 8
(4,055 Views)