LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compare multiple values

Solved!
Go to solution

Basically, I have four string values that I need to compare.  If any 2 or more of them are identical, I need to send a message back to the user, asking them to change one of them, while preventing additional operations from having them.

 

I am sure that using enough =?, ANDs and ORs that I can accomplish this, however I feel like there must be a more simple solution.

 

Any thoughts?

Message 1 of 9
(9,915 Views)

If you do a search you will find that this question has come up before. One solution is to create two separate arrays from your strings and then use a for-loop to iterate through, using one array as the auto-indexer and then look for that element in the other array. Send out a Boolean value and then AND or OR (depending one which comparison you picked) the resultant Boolean array. Shouldn't be too difficult for you to code up.

Message 2 of 9
(9,901 Views)

That makes a lot of sense.  I had searched, but perhaps used the wrong terms, as I didn't find much.

 

Thanks much, I will try it out.

0 Kudos
Message 3 of 9
(9,896 Views)

You can use the array, do a compare which generates a boolean array. Convert the boolean array and sum it up and check if the difference is >= to 2.

Message 4 of 9
(9,895 Views)

I just did something similar the other day. This is how I went about it.

 

Example_VI_BD.png

=====================
LabVIEW 2012


Message 5 of 9
(9,891 Views)

The OpenG Array palette has a function to remove duplicates from a 1D array that you can use to find duplicates and their indices.

 

Example_VI.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 6 of 9
(9,862 Views)
Solution
Accepted by topic author krwlz101

Identify Duplicates.png

 

This is what I ended up doing, and it seems to work great.

0 Kudos
Message 7 of 9
(9,851 Views)

Hi krwlz,

 

one small change may result in huge speedup (for large arrays):

original.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(9,834 Views)

The speed up is due to the fact that I would not be processing a large array of booleens on the exit from the loop?

 

I don't actually want to stop the overall loop in the case of a duplicate, I just want to change what happens.  Is there a way to do this without the stop button?

0 Kudos
Message 9 of 9
(9,824 Views)