LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Verify all values of hex array have occured.

Solved!
Go to solution

I am reading hex values from a controller I want to match when certain messages occur and when all have occured I want it to stop the loop. Below I have a base of what I want but I can't figure out how to notify when all values of the array have been met.  I took the VISA serial commands out an I am just using this little setup first. 

 

The "Match First String" funtion is being used, it would be nice if it would output when a match has been met and then I could build and array and compare it to the input array but, I can't seem to solve this. 

 

I also tried to use the index output and alert when an addition of the elements have been met, but I want to avoid duplicates that would affect the total sum. Any insight on this would be helpful. Thank you !

Download All
0 Kudos
Message 1 of 5
(1,161 Views)

Initiailize a boolean array of false values the same size as your string array.

Whenever you find a match in the string array, replace the value in the boolean array with a True.

You'll know you have found all elements when AND Array Elements functions on the boolean array returns a True.

0 Kudos
Message 2 of 5
(1,156 Views)

Hi,

 

The 'Match First String' index output -1 if no match is found, you can wire it to a 'Greater or equal to 0?' comparator such that it output 'False' if no match if found. You can then wire this to a case structure and wire the original string input into the case and process it in the 'True' case which is when a match is found.

 

Capture.PNG

 

You can refer to this link on how to remove duplicate from array.

0 Kudos
Message 3 of 5
(1,141 Views)

@TCChun wrote:

You can refer to this link on how to remove duplicate from array.


LabVIEW 19+ has a VIM in the array palette that does it using a set. much simpler!

 

For the original problem create a set of matching number (instead of an array). Use "remove from set" with each new string. Once the set is empty, all values have occurred. (Look in the new "collections" palette).

0 Kudos
Message 4 of 5
(1,097 Views)
Solution
Accepted by topic author Montn

@altenbach wrote:
For the original problem create a set of matching number (instead of an array). Use "remove from set" with each new string. Once the set is empty, all values have occurred. (Look in the new "collections" palette).

Here's how that could look like:

 

altenbach_0-1597648230817.png

 

Message 5 of 5
(1,093 Views)