01-12-2009 01:55 PM
Here's the situation. I have an array of, say 25 elements (for example, representing possible positions of the trailers.) I have a FOR loop that goes through each one and applies a test, say coming up with 3 valid results (again, for example, where the right color is over the other color.) I would like to build an array of just those three results. Okay?
Right now, I feel that I have to build an array of 25 on the output side to match the input side. If something is good, I set a boolean to true - if it isn't good, I set that boolean to false. I then do a subsequent WHILE loop that does a DELETE FROM ARRAY - so I end up with a list of 3 good elements.
There must be a better way... Any hints or thoughts?
(Although it may not seem like it - I am starting to get the hang of this approach...)
01-12-2009 09:15 PM
I'm not sure I completely understand what you are trying to do; so, if I'm off base, let me know. My recommendation is to output these three values on their own rather than as elements in an array. If you need to propagate these three values from one iteration of the loop to the next, you can use shift registers to do so (right-click where the wire leaves the loop).
Also, feel free to post a small example of what you are doing which may make it easier for other to offer suggestions.
Hope this helps,
Geoff Schmit
Sponsor/Mentor Team 3061
Naperville North High School
01-12-2009 10:42 PM
You need to use a shift register to build an array dynamically.
See the example located at: c:\Program Files\National Instruments\LabVIEW 8.5\examples\general\arrays.llb\Separate Array Values.vi
OR see the attached VI.
These topics can be reviewed here: http://zone.ni.com/devzone/cda/tut/p/id/7466
01-13-2009 07:22 AM
Perfect - thanks. I had taken the tutorials - but I hadn't grasped this aspect (subtlety?) of shift registers around FOR loops. It's actually very neat - but for us old timers a little unsettling...