LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I insert strings into an array? I tried to use the spreadsheet string to array block and it did not work.

Solved!
Go to solution

So I am reading channels from a TDMS file and I would like to insert only channels that contain words "Mod" into array so that it looks like the picture below:

Capture1.JPG

Below is my block diagram (I do not know how to fix that broken wire). Also, I attached my VI and the tdms file that I'm reading data from.

Capture1.JPG

Download All
0 Kudos
Message 1 of 19
(6,179 Views)

You have been on this board for over two months, it is about time you started taking some tutorials. Look at your VI, it makes little sense. You connected an array to a string, hence the broken wire.

 

You have a loop to index elements of an array. You are reading the whole array every loop and then picking out an element to see if it has Mod in it.

Read the array once, (All that TDMS stuff should be outside the loop), then loop through the elements of the array to find values you want, like below.

 

Snap19.png

VI is not included; by copying the above picture, you will at least learn a bit.

 

mcduff

 

 

0 Kudos
Message 2 of 19
(6,158 Views)

Filtering the channels can be done using the code below:

Filter Channels.png

Search/split string function breaks the wire because it does not accept an array as an input and cannot return an array as an output. If you can give more details about what you want to achieve maybe we can give some guidance because the code that you attached does not make too much sense.

Lucian
CLA
0 Kudos
Message 3 of 19
(6,150 Views)

The TDMS has a lot of channels, but I am only trying to insert channels that have the word "Mod" array such that the array looks like the one below. I am trying to achieve it using search/split string. If you have a different way or know the best way to do it, please share it. I'm here to learn that's why I am asking questions. I don't know everything and no one can claim to know everything.

Capture1.JPG

0 Kudos
Message 4 of 19
(6,115 Views)

McDuff's Response (#2) showed you the method.  Start with an Array of Strings.  Run it through a For loop (which lets you work with a single element).  Do your test (here a simple Search String).  If you don't know how Search String works (and how it can detect if "Mod" is or is not present), right-click the Function and read its Detailed Help. Finally, use this information to return a value to the output Indexing Tunnel only if the Condition is met.  If you don't understand Conditional Tunnels, go through the Tutorials on For Loops and Arrays and Tunnels again.

 

Bob Schor

0 Kudos
Message 5 of 19
(6,102 Views)