09-09-2011 10:26 AM
I have a stacked sequence structure with 15 iterations. Is there a functional equivalent to the "i" from the For loop or a way to make one?
I need to trigger some other events based on what iteration of the stacked sequence is running.
09-09-2011 10:44 AM
In a sequence structure they are called frames rather than iterations. And you have run into one of the reasons why sequence structures are usually not the best arrchitecture for involved programs: They are hard to modify and essentially impossible to branch.
You can context-click on the edge of the frame and choose Replace with Case Structure. Enclose the case structure in a while loop. With just a little extra effort you will have a state machine which is much more flexible.
Lynn
09-09-2011 10:50 AM
Hi,
you can put numeric value 0 to case 0, then pass that value + 1 to next stack (right click the sequence structure, add sequence local). It would be better design to use state machine than sequence structure.
09-09-2011 11:26 AM - edited 09-09-2011 11:28 AM
Let me first reiterate what the others have said. Avoid stacked sequences like the plague!
I have found that except for very few situations there is always a better way then using a sequence structure.
That being said you could use a local variable to do this too...
09-09-2011 11:31 AM
I've convinced myself it's better to use a proper state machine.
So to do this, the best method is to have 15 serparate case structures, and place that into a while loop with N=15?
..then read the iteration number, and depending on that logic, select the proper case structure within the while loop?
09-09-2011 11:37 AM
@Synbios wrote:
I've convinced myself it's better to use a proper state machine.
So to do this, the best method is to have 15 serparate case structures, and place that into a while loop with N=15?
..then read the iteration number, and depending on that logic, select the proper case structure within the while loop?
That should be ONE case structure, containing 15 different cases. Then you wire the iteration number directly to the ? terminal of the case structure.
09-09-2011 11:39 AM
That makes sense. thanks!
09-09-2011 11:51 AM - edited 09-09-2011 11:52 AM
May I humbly suggest this article: Application Design Patterns: State Machines
You can create a state machine using the VI template that ships with LabVIEW. File -> New... Then expand the "From Template" branch.
09-09-2011 11:56 AM
In your example though, how do you get the dark bolded local variables? Or the part of the first frame that says I32 Iteration.
09-09-2011 12:04 PM
They're drawn that way automatically my setting the local variable to "read". With the addition of the little arrows (as a consequence of an idea submitted in the LabVIEW Idea Exchange) it's somewhat redundant now.