LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem in removing empty string from array

I want to delete empty strings from my array, i have made the program for removing, it is working fine for all other array of strings, but for my input array it is not deleting empty strings.

 

Below i am attaching vi.

0 Kudos
Message 1 of 7
(3,825 Views)

I forgot to attach the vi in the last post, here is the vi.

 

Thankyou

0 Kudos
Message 2 of 7
(3,821 Views)

Your strings aren't empty.

 

Change the display style for the strings to either hex display or \codes display.  You'll see that your "empty" strings actually contain a tab character.  Actually all the array elements begin with a tab character (probably left over from some parsing of a tab delimited file?)

 

Go through your array and do a search and replace to eliminate all of the tab characters with nothing.  Then put it through your loop.

Message 3 of 7
(3,817 Views)

In other way you can use the "Trim white space" function and eliminate the tab constants.

 

TrimWhitespace.png

 

Good luck

-----

The best solution is the one you find it by yourself
Message 4 of 7
(3,799 Views)

Easiest would be to just look if the string size is 1 or less. It is not good coding practice to use "delete from array" in a loop, because the constant array resizing causes memory allocation issues. Here's how to do it in-place, then trim at the end.

 

 

This could be made even simpler with the implementation of this idea, so please vote for it :))

 

(Also note that your original code is incorrect, because the FOR loop spins way too many times. you should use a while loop instead and stop when nothing is found anymore).

 

 

 

 

Download All
Message 5 of 7
(3,779 Views)
altenbach,
-i just thought about the number of times its iterating. and how about using conditional iteration for loop instead of while loop?
-For me it looks like for loop with condition terminal will be good (can you please tell me) after looking at this link
http://www.ni.com/white-paper/6285/en/
Thanks
uday
0 Kudos
Message 6 of 7
(3,769 Views)

@udka wrote:
-For me it looks like for loop with condition terminal will be good (can you please tell me) after looking at this link

There are dozens of diferent ways to do this, and the choice of loop is probably a minor issue. The rest of the algorithm is probably more important. 😄

 

0 Kudos
Message 7 of 7
(3,759 Views)