LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
LuI

provide a 'last element' terminal for autoindexed arrays in while loops

Status: Declined
Functionality is already built into a For Loop by using auto-indexed tunnels to determine the array size and also adding a conditional terminal to the loop.

While loops are often used to process elements in an array. Search shall be aborted either when a given condition is fullfilled or when all array elements have been processed. For this reason one has - outside the while loop - to get the array size, decrement by 1 and - inside the loop - compare this number with the actual iteration terminal. This must be combined with the result of the above mentioned processing in order to determine if the loop must reiterate or stop. if instead a 'last element' terminal in the loop was provided, the explicite calculations aouside of the loop could be avoided and with it the real estate this takes.

BTW, 'last element' should keep true whenever it became true in a loops execution.

5 Comments
tst
Knight of NI Knight of NI
Knight of NI

LabVIEW has had the ability to add a conditional terminal to the for loop since LV 8.5. This should fulfill your requirement.


___________________
Try to take over the world!
LuI
Active Participant
Active Participant

Edited: misspelling cleared

 

 

This is not the same but could probably be used. I had no 'mental connection' to the abortable For-loop; maybe due to sticking to what I once learned as the fomal definition of For-loops as being an iteration statement with beforehand known number of iterations.

Thx for the hint!

 

 

G-Money
NI Employee (retired)

When you wire an array to a For Loop and leave it auto-indexed then it will automatically iterate the number of elements that are in the array. You don't need "prior" knowledge to determine what to wire to the count terminal. You can leave the count terminal blank and let the auto-indexing do everything for you (http://zone.ni.com/reference/en-XX/help/371361G-01/glang/for_loop/).

G-Money
NI Employee (retired)
Status changed to: Declined
Functionality is already built into a For Loop by using auto-indexed tunnels to determine the array size and also adding a conditional terminal to the loop.
LuI
Active Participant
Active Participant

G-Money,

 

I am OK with your status change. But you seems to have not understood what I was trying to say with my comment.

I once learned that for a FOR-loop the number of iterations have to be determined befor starting the iterations. So I never thought on the abort the iteration with a conditional terminal. I instead used a while loop that checked for the abort condition AND the number of iterations (in case the abort condition did not become true during all iterations).

Sorry for my bad english!

--

Greetings from Germany 😉