11-10-2011 12:23 PM
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?
Solved! Go to Solution.
11-10-2011 01:43 PM
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.
11-10-2011 01:50 PM
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.
11-10-2011 01:52 PM
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.
11-10-2011 02:07 PM
I just did something similar the other day. This is how I went about it.
11-11-2011 04:43 AM
The OpenG Array palette has a function to remove duplicates from a 1D array that you can use to find duplicates and their indices.
11-11-2011 07:03 AM
This is what I ended up doing, and it seems to work great.
11-11-2011 09:00 AM - edited 11-11-2011 09:01 AM
11-11-2011 09:47 AM
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?