LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Darin.K

Reverse Iteration Terminal in For Loop

Status: New

It has been a few months since a suggestion has been made to do something about the For Loop, so if nothing else it is time to stir things up a little bit.  There have been several suggestions to do something with the iterators, for example:

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Smart-Iterators-with-Loops/idi-p/967321

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/for-loop-increment/idi-p/1097818

 

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/quot-Start-Step-Stop-quot-structure-on-For-loops/idi-p...

 

None of these has really gained traction, and heck, I haven't settled on any of them myself.  In most cases I am satisfied with a workaround, usually involving the Ramp VI.

 

There is one case where I am not happy with the workaround.  I happen to need reverse iteration values quite often (N-1,N-2,...0).  With the N terminal pinned to the top-left corner I have little choice but to do the following and start zigging and zagging wires:

 

18391iB5AE9450400CAAD6

 

I would simply like a reverse iteration terminal which can be moved around at will and simply counts down.  Doesn't have to look like I have drawn it, that just happens to be intuitive to me.  Naturally this terminal (and the normal iteration terminal) should have the option to be hidden.

 

I thought about having the option to have the loop spin backwards, similar to reversing all auto-indexing inputs and having the iteration terminal count down, but I just could not decide what to do about auto-indexed outputs.  My G-instincts tell me that they should be built in the order of loop cycles, my C-instincts tell me I am building array[i] and if i goes in reverse order, so should the array elements.  For now I say, forget it, and just stick to the simple terminal.  Array reversal is essentially free, so I at least have a workaround there.

37 Comments
JackDunaway
Trusted Enthusiast

I'm voting for the sake of traction, with my favorite implementation still being the first link. (Ability to change iterator datatype is also a boon, just throwing that out there again.)

altenbach
Knight of NI

What if the reversed [i] terminal looked the same, but had a small "invert" circle at the output on the right side?

Darin.K
Trusted Enthusiast

"What if the reversed [i] terminal looked the same, but had a small "invert" circle at the output on the right side?"

 

Only if they Enlarge The Invert Circles....

 

Seriously, that is an excellent suggestion.  I thought about using 'j' as the reverse iterator as well.  Not that the notion that j=-i has caught on beyond some truly nerdy types.  (insert missing laughing emoticon here).

AristosQueue (NI)
NI Employee (retired)

What if the terminal said "N - 1 - i" instead of the current "i" ? That would accurately describe exactly the calculation that is going on. The invert circle means negate, and just negating the i value is not what you want --- that would yeiled values of zero through negative N-1.

 

Alternatively, I could imagine changing the existing i terminal to be "i" with a small up arrow (still fitting inside the current bounding box so the terminal doesn't get bigger), and then having a down arrow when you configured it to count down.

 

Those are the two ideas that come quickly to my mind. Regardless of the specifics, I've kudos'd the idea.

Intaris
Proven Zealot

What about "i++" and "--N".  Would that be accurate for C-heads?

altenbach
Knight of NI

> The invert circle means negate, and just negating the i value is not what you want...

 

Yes, that bugged me somewhat when I posted, but then I thought that the little circles are already overloaded in meaning.

 

 

  • Add compound node: negate the input (-x)
  • multiply compound node: reciprocal of the input (1/x)
  • boolean compound node: "not" of the input (.not. x)

 

(... and similar for the output, of course)

 

So, yes, a circle on N could mean many things, ( -N, 1/N, or bitwise_not_N), so we need to define it in the help anyway. As long as it is defined as "reverse order of normal", it might be clear enough... or maybe not.

 

That's why we need to discuss it. 😄

 

 

JackDunaway
Trusted Enthusiast

Overloaded, but well defined. Negate is the arithmetic inverse, reciprocal is the multiplicative inverse, NOT is the Boolean inverse. Is Decrement the Increment inverse, or opposite?

 

Semantics.

 

This is why I'm going to lean toward the first link (I have copied the image below). Setting a negative step will implicitly define the direction which the Iteration Terminal moves, and with this implied directionality there doesn't need to be a new graphical distinction.

 

After thinking about it, I would change the terms "min" and "max" to "Begin" and "End".  That way, for instance, you could set Begin=10, End=0, and Step=-0.1, which is more readable.

 

stepped-loop.PNG

altenbach
Knight of NI

> After thinking about it, I would change the terms "min" and "max" to "Begin" and "End".  That way, for instance, you could set Begin=10, End=0, and Step=-0.1, which is more readable.

 

That might be weird too, because the values are correlated. For example

 

 Begin=10, End=0, and Step=+0.1

 

Would make little sense.

 

Maybe [Start, Step, N] would be better?

AristosQueue (NI)
NI Employee (retired)

> Maybe [Start, Step, N] would be better?

 

Yes.

 

These comments need to be reposted in the other thread. They will not be noticed here if that other idea gets bought.

altenbach
Knight of NI

It is already "sort of" mentioned in the first link, but maybe not in the same words.... I'll add a few sentences....