LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem in deleting elements from array

Solved!
Go to solution

i want to delete some particular instruments from array (in given program the element starting with for, loop and end) for which i am using search 1d array to get indices and then usign delete from array, but it is not deleting all the elements, or the output is not coming as expected.

 

Attached is the vi which i am using to delete elements from array.

0 Kudos
Message 1 of 9
(5,257 Views)

I'm not sure I understand what you're trying to delete.  Is it just the 'For' and 'End' lines in your example or all the lines from 'For' to 'End', inclusive?

 

One reason you're not seeing correct results is that in the right for loop you need to be using a shift register for the loop from which your deleting, otherwise, each iteration of the loop starts with the original array and you'll only see the result of the last delete, which is why 'End' is gone but 'For' is not.  You'll also need to regenerate the search list after each delete or the indicies from Search 1D Array will not be correct.

0 Kudos
Message 2 of 9
(5,246 Views)

Thanks DAD for the reply,

 

i just want to delete only the Lines containing For & End not all the lines from For to End

 

yes i know i need to use shift register, earlier i used to do tlike this but in this case since the array from which i am searching and the array from which i have to delete are different so not able to implement properly how to do this 

0 Kudos
Message 3 of 9
(5,243 Views)

Hopefully someone will provide a more efficient example.  But here's your VI modified to give the result you're looking for.

0 Kudos
Message 4 of 9
(5,232 Views)

can you please upload the vi in LabVIEW 11 version 

0 Kudos
Message 5 of 9
(5,230 Views)
Solution
Accepted by topic author RChoudhary
Message 6 of 9
(5,217 Views)

Don't overcomplicate things!! All you need is one loop and one pass through the array.

 

 

 

Download All
Message 7 of 9
(5,192 Views)

@altenbach wrote:

Don't overcomplicate things!! All you need is one loop and one pass through the array.

  


As you say Do more with less code and in less time suits best here.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 8 of 9
(5,179 Views)

@DAD wrote:

Hopefully someone will provide a more efficient example.  But here's your VI modified to give the result you're looking for.


This VI is broken.

It will only remove the first occurce of each special line. For example, if there is more than one "for" line, only the first will be removed.

 

It is also very memory inefficient due to the constant resizing of the array in the shift register.

It is also inefficient, because each kept line is parsed N times in a row with the same pattern. This is 3x the work actually needed. Once is enough.

0 Kudos
Message 9 of 9
(5,155 Views)