08-28-2018 05:05 PM
Hello,
I have a sub VI that takes accepts a Boolean for if it is the first time this Sub VI is run based on conditions of the Main VI. If it is the first time that the sub VI is run (incoming Boolean = TRUE) I want the cluster of buttons to all be enabled. One of the functions of this sub VI is to disable the buttons as certain actions are completed by the user. However, I have found that if the user completes the necessary tasks, stops the main VI (as intended once they are finished with the program) and then starts the main VI up again, when they go into this sub VI on the 2nd run, the same buttons are disabled from their 1st run. I have attached a sample code that replicates the issue along with 2 attempts I have tried at fixing it, re-initializing all values in the sub VI, which doesn't work because an enabled state isn't a value that can be reset to its default, and enabling the cluster, which doesn't enable all of the buttons within the cluster.
Any help that can be provided is much appreciated.
Solved! Go to Solution.
08-28-2018 05:21 PM - edited 08-28-2018 05:25 PM
Why do you even need a boolean control if we have this function? 😄
To enable all cluster elements, you need to iterate over them, e.g. as follows:
08-28-2018 05:31 PM
I didn't know that first call function existed. Thanks for that and the solution to what I was originally asking!
08-30-2018 12:26 PM - edited 08-30-2018 12:30 PM
@altenbach wrote:
Why do you even need a boolean control if we have this function? 😄
To enable all cluster elements, you need to iterate over them, e.g. as follows:
I've never used the "First Call" function before (although I've known about it for a very long time). What would you use it for? Seems like natural dataflow always took care of those issues for me.
Just like once I was asked if I ever used a semaphore before; I confessed I never felt the urge to. That person got snooty and said that you can't be a true LabVIEW programmer if you never used one before. I always thought that if you planned everything out carefully, you didn't need to use one.
08-30-2018 12:46 PM
I am using it as the input to a case structure, if it is the first time the sub VI is called, then I want the sub VI to reinitialize everything back to its defaults. Throughout the course of the sub VI's use, some of the buttons on my boolean cluster get disabled and the boolean text is populated with a numeric value for future calls to this sub VI during the same run of the main VI. So if the incoming value to that case structure from the "First Run" call is false, I want the sub VI to hang on to the disabled buttons and the boolean text that they have been assigned.
08-30-2018 03:10 PM - edited 08-30-2018 03:10 PM
@billko wrote:I've never used the "First Call" function before (although I've known about it for a very long time). What would you use it for? Seems like natural dataflow always took care of those issues for me.
A very common use can be found inside all ptbypt function that have an "initialize" terminal (examples). Each reentrant instance needs to initialize if that terminal is true OR unconditionally on first call.
Often action engines using shift registers need to initialize the shift registers on first call (they cannot be initialize shift registers, because, they need to retain data between calls!). However, these days I use feedback nodes instead, because they have a global initialization option that makes "first call?" no longer needed.
08-30-2018 04:11 PM
@altenbach wrote:
@billko wrote:I've never used the "First Call" function before (although I've known about it for a very long time). What would you use it for? Seems like natural dataflow always took care of those issues for me.
A very common use can be found inside all ptbypt function that have an "initialize" terminal (examples). Each reentrant instance needs to initialize if that terminal is true OR unconditionally on first call.
Often action engines using shift registers need to initialize the shift registers on first call (they cannot be initialize shift registers, because, they need to retain data between calls!). However, these days I use feedback nodes instead, because they have a global initialization option that makes "first call?" no longer needed.
LOL - it's my coding style that precludes me from using it, I see. In the case of the A/E that you pointed out, I would have explicitly made an init state that I would call before I actually needed it. But I now see that it means an extra step. If I used "First Call", I could skip that init step. Always learning - and that is EXACTLY why I asked.