LabVIEW Idea Exchange

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

Conditional Terminal Initial Conditions

Status: Declined
From AristosQueue: "The value of the "Last Value" terminal was specifically chosen to be the default value for the data type if it never gets assigned. This provides an easy-to-guess result for anyone looking at this syntax. There was not a convenient syntax to supply alternate default values without significantly complicating the syntax of the feature (for example, some sort of paired left-side-of-structure input tunnel). If you want such an alternate value, use a shift register and update within a case structure."

The current for loop has conditional terminals that are very useful for array manipulation. The conditional terminal could be improved for last value mode. Adding the ability to set up an initial conditions would make simpler code. For example I want to do the following.

eg1.png

This will produce a 2. If a string containing sort does not exist this will produce a -1 (not found). The problem with the current implementation of the conditional terminals is that it sets the not found value to the default value for that type.

This example would return 0 if sort does not exist in any of the strings, the same result expected if sort exists in the first string of the array.

eg2.png

 

I propose the initial condition terminal where you can define what to use if the conditional terminal is false.

eg3.png

 

5 Comments
crossrulz
Knight of NI

Are there other use cases than just a search algorithm?

 

For my searches, I don't use the conditional tunnel since I am exiting as soon as a match is found.  I also pass out the Conditional Stop value.  Then I can throw an error if the item wasn't found.  In your case, you can just use a simple Select after the loop to define a -1 if the item was not found.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
fabric
Active Participant
One important use case is for loops that may execute zero times, e.g. For loops auto-indexed by dynamic-sized arrays.
LordNobady
Member

This can be usefull for searches and database functions. I can imagen that there might be some matimatical operations that rely on some conditions that this can be used for to. 


Learning LabVIEW since January 2013
X.
Trusted Enthusiast
Trusted Enthusiast

Related discussion here.

Darren
Proven Zealot
Status changed to: Declined
From AristosQueue: "The value of the "Last Value" terminal was specifically chosen to be the default value for the data type if it never gets assigned. This provides an easy-to-guess result for anyone looking at this syntax. There was not a convenient syntax to supply alternate default values without significantly complicating the syntax of the feature (for example, some sort of paired left-side-of-structure input tunnel). If you want such an alternate value, use a shift register and update within a case structure."