09-12-2013 07:05 PM
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.
Solved! Go to Solution.
09-12-2013 07:51 PM
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.
09-12-2013 08:01 PM
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
09-12-2013 08:32 PM
Hopefully someone will provide a more efficient example. But here's your VI modified to give the result you're looking for.
09-12-2013 08:36 PM
can you please upload the vi in LabVIEW 11 version
09-12-2013 08:53 PM
saved for 2011
09-13-2013 12:15 AM - edited 09-13-2013 12:27 AM
Don't overcomplicate things!! All you need is one loop and one pass through the array.
09-13-2013 12:53 AM
@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.
09-13-2013 10:59 AM
@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.