LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search an array for values that don't match?

Solved!
Go to solution

My user will be uploading a list of commands which are then read off sequentially and sent as messages to different loops in the system.

Every line of this array must be in the exact format the loops are expecting, or the loop will receive an unknown string and error. 

 

I want to be able to check through this list for anything that doesn't match one of the 5 expected commands. Like a 'does this string exactly match any of these strings?' yes/no 

 

So far all I can think is using 5 different while loops containing the search array function. Each of these will increment through the array searching for a different command, if all 5 of the while loops give a -1 then the array line hasn't matched any of the commands so will trigger an error to the user (as one of the commands must be mistyped). 

 

But that sounds absurd? 

 

 

-------------------
CLD
0 Kudos
Message 1 of 4
(2,847 Views)

Create a string array constant of executable commands to compare with the array of commands that have been read from your user. Use a for loop to index the user commands and check each one using "Search 1D Array" against the array of possible commands. If the result (index) is >=0 then you have a match. AND "And Array Elements" all of them to see if they all are good.

Message 2 of 4
(2,836 Views)

Depending on the format of the commands, it can be either a simple list you check against with a Search 1D Array, or if more dynamic a list of 5 regexps. If it's even more advanced you're into language interpretation and need recursive functionality, like with a typical text programming language with loops within cases within structures ...

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 4
(2,822 Views)
Solution
Accepted by topic author Shiv0921

You can compare each with an array of valid commands or with a set of valid commands.

 

Here are two examples to clean the array of commands:

 

You could even do the "sending" right inside these loops and only send the valid command using a case structure.

 

altenbach_0-1591977518920.png

 

Message 4 of 4
(2,789 Views)