02-09-2012 12:31 PM
@smercurio_fc wrote:
That sounds like someone trying to create a state machine, but not completely understanding the concept. Or perhaps the programmer had read about how sequence frames are "evil" (which they are not, if used correctly), and decided to do it that way instead.
In some cases it may be useful. Just enum, and loop (I prefer while, but may be "for" loop as well) which runs for all values sequentially. It looks like sequence (and act as sequence), but all frames are named - its good for readability and navigation. Kind of "reduced" State Machine, something like that:
02-09-2012 12:34 PM
... or the orginal develper did not want to use sequence locals in a stacked seq so they invented a stacked quence where they could use SRs instead.
Can you share an image of the curiosity?
Ben
02-09-2012 12:59 PM
I've done this to parse a string into a cluster where the string contained embedded strings preceeded by a string length, so I couldn't use several instances of string subset in parallel. Each case removes the appropriate length from the beginning of the string, fills in an element of the cluster, and stores the remaining string to a shift register.
02-09-2012 01:02 PM
thanks Nathan!
A stacked sequence that can use a SR.
Ben
02-09-2012 01:21 PM
>Can you share an image...
Sorry, can't post any code from the project. I could recreate the code and post it, however I think I figured it out. I did look at the code a little more and I'm convinced there is a better way. The ouput of the case statement goes into a sub-vi that does a "replace array subset" for each interation, Read of Global Array to Write of Global array.
As the code is for initialization, I believe that the For Loop and Case can be eliminated and replaced with one instance of Replace Array Subset. Replace Array Subset could be expanded to handle all of the 10 indexed items and can be more easily maintained without stacked/flat sequences.
Or even better (IMHO)
The Global Array could be replaced with a functional global and the functional global would have an initialize function that would take in a 10 element array and perform the "Initialize Array" for size and "Replace Array Subset" for data entry in the Initialization case.
What do you think?