09-23-2019 09:05 AM
See attached VI. I want to delete the elements from this array that don't start with OB1. How do I do this?
09-23-2019 09:26 AM
Note that the Example String you provided has no lines starting with "OB1"!
You have a multi-line string. The first thing you want to do is to convert it to an Array of Strings. This is not a difficult function to write, but it's even easier to use the "String to 1D Array" function from the OpenG String functions available on the LabVIEW Tools Network (accessed with VIPM, the VI Package Manager, which should have been installed with LabVIEW, but otherwise is a free download from JKI.net) (go ahead and install the OpenG Toolkit, which gives you additional Useful Functions that NI is gradually (over >12 years) adding to LabVIEW).
Now you can pass the Array into a For loop, which allows you to test each element one at a time and get "True" (meets your Criterion) or "False" (fails to meet your Criterion). Bring this to the output Indexing Tunnel, and assuming you are using a version of LabVIEW less than 6 years old, right-click on the Tunnel, add the Conditional qualifier, and wire the output of the Test to the "?" terminal. Your output Array will be just what you want, those elements where the test was True (or an Empty Array if none of them match).
Bob Schor
09-23-2019 09:32 AM
Well, you almost have it!
You already succeeded in splitting the string and removing the first parts of it. The only mistake now is that you check on the first three characters is outside of the for-loop. You should do the comparison inside the for-loop, store all the correct ones in a new array and wire this to the loop output.
09-23-2019 09:39 AM
Something like this:
09-23-2019 09:58 AM
09-23-2019 02:20 PM