06-14-2013 10:39 PM
I have a stack sequence with 10 frame defines, there is a wait to delay 2 seconds between each frame. I have a common string indicator defined and I would like to output a string to that indicator in the very first frame before the codes between frame 2 to frame 9 is run ... and I would like to output another string to the same indicator at the very last frame to indicate all code finished. But I find that there is no way to share the indicator by two constant string defined in different frame. Any idea? Thanks.
Solved! Go to Solution.
06-14-2013 10:45 PM
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours
Use a flat sequence rather than a stacked sequence. The stacked sequence hides code unnecessarily.
06-14-2013 10:46 PM
Use local variable or property node value of that common indicator in all the sequences
06-15-2013 07:49 AM
Stacked sequences are not recommended in general, and you should rewrite your code into a proper state machine. Now keep the string in a shift register and append to it whenever a state needs to do so. Update the indicator outside the state cases, once per iteration of the outer loop.
If you keep adding code to a fundamentally flawed architecture, you'll simply have more problems cleaning up the code in the future. Do it now, while the code is still manageable! 😄
I strongly recommend against the use of local variables in the way outlined by some others. You are simply making bad code even worse. For each operation you would need two local variables (read from local, modify, write to local), cluttering and complicating the code structure unecessarily, creating additional data copies in memory, and potentially introduce race conditions because there is no way to tell what code section wrote to it last.
If you need help redesigning the code, post it here and we can give some recommendations.
As a quick bandaid solution, you could also keep the string in an action engine with several modes (read(default), init, write, append, etc.).
06-15-2013 08:54 AM
I completely agree with Altenbach that state-machine design are significantly more advantageous - especially when design starts growing. It is fairly easy to replace your stacked structure into a case-structure based state-machine design... attached is an example on how to do that. It may look like extra coding at first, but once you get a bit used to LabVIEW you'll see how easy it is to expand upon.