05-27-2015 10:02 PM
Hello all,
I need small help. Please help me.
I want to validate some syntaxes like below. Is there is any default LabVIEW function for this?
OK Type:
(((1 AND 2) OR 3) OR 4)
(((1 AND 2) OR (3 OR 4)) OR 5)
NG Type:
((1 AND 2) OR (3 OR 4) OR 5)
(( 1 AND 2 OR 3) OR 6)
(1 AND 3 OR 3
I need to check above syntax is correct or not (like brackets are properly opened & closed, AND/OR etc.).
I created sample VI for this but in some cases it is giving wrong result (eg: ((1 AND 2) OR (3 OR 4) OR 5)) .
05-27-2015 10:32 PM
Brackets should be easy enough - the number of times "(" appears" is the same as ")" and the first and last instance of each must be those respectively.
05-27-2015 10:56 PM - edited 05-27-2015 10:57 PM
we cant judge syntax only by open & close bracket.
For example. ((1 AND 2) OR (3 OR 4) OR 5)
Here "(" count is same as ")" but it is NG case.
Correct Synatax: (((1 AND 2) OR (3 OR 4)) OR 5)
05-27-2015 10:58 PM - edited 05-27-2015 11:02 PM
@Munna232 wrote:
we cant judge syntax only by open & close bracket.
For example. ((1 AND 2) OR (3 OR 4) OR 5))
Here "(" count is same as ")" but it is NG case.
Correct Synatax: (((1 AND 2) OR (3 OR 4)) OR 5))
Your NG example has 3 "(" and 4 ")". So I'm not sure I understand your point. But you also haven't clarified what rules you are trying to enforce or any other context for your question. Until you do I don't think I can help.
EDIT - I see you have updated your example to fix the last ")". But I still don't understand what you are trying to achieve. If 1 to 5 are boolean inputs then your NG example is perfectly valid boolean arithmetic syntax. You need to provide a better context for what you are trying to achieve.
05-27-2015 11:22 PM
State your requirements... as a set of requirements! Not only will it help us, but you may come up with the solution yourself.
05-27-2015 11:23 PM
Hello Tyk007,
Sorry for the confusion.
1 to 5 are Boolean but we want to do logical operation for only two at once.
For example:
(1 OR 2 OR 3) à this is correct for logical operations. But we want to do two at a time.
It means ((1 OR 2) OR 3) , other way (1 OR (2 OR 3)).
So, if user is giving syntax like (1 OR 2 OR 3), we need to make it NG type. Like this I need to check different combinations to validate the syntax.
05-27-2015 11:34 PM - edited 05-27-2015 11:34 PM
This might be one of those times where telling us "why" you need to have it done is more valuable than "what" you want done.
05-27-2015 11:46 PM
05-27-2015 11:49 PM
Here is updated code.
I'm really sorry if my required is not clear.
Please let me know where your getting confuse.
05-28-2015 03:19 AM
I did little modifications.
I think it will cover all combinations.
Please let me know if there is any modifications required.