01-21-2018 11:03 PM
Hello ! i have a cluster containing 256 boolean elements , which i am using as checkboxes for my application. I want to add cancel button functionality to my application, so that when i click the cancel button, all the changes that i have done on the checkboxes revert or goes back to previous state. Can u please tell me how can i implement this ?
Solved! Go to Solution.
01-21-2018 11:34 PM - edited 01-21-2018 11:37 PM
@shaunmarsh123 wrote:
Hello ! i have a cluster containing 256 boolean elements , which i am using as checkboxes for my application. I want to add cancel button functionality to my application, so that when i click the cancel button, all the changes that i have done on the checkboxes revert or goes back to previous state. Can u please tell me how can i implement this ?
Use a Functional Global Variable to perform Read/Write actions, see snippet below. You can just store the actual cluster state inside this FGV, and when the user selects "cancel" in the corresponding Event case, read out the previous content of the FGV, and use a Local Variable of your cluster in write mode, to revert back to the prev state...
By the way, to use such monstrous cluster seems a bit counter-productive. I would use a 2D array of Boolean+text clusters, much more scaleable and you can easily access array elements. Much better than what you do now... See example here: https://forums.ni.com/t5/LabVIEW/Create-checkboxes-programmatically/td-p/3664192
01-21-2018 11:41 PM
Write back to the control via a local variable.
To make all FALSE, do a "AND FALSE".
To make all TRUE, do a "OR TRUE".
(boolean operations with a single diagram constant)
01-21-2018 11:58 PM - edited 01-22-2018 12:04 AM
01-22-2018 12:22 AM
@altenbach wrote:
@altenbach wrote:
Write back to the control via a local variable.
Here's a very simple demo.
You forgot the question was about a "cancel" or "revert back changes" functionality. But using your VI, the OP can easily implement the required option (or using the FGV I showed, or a shift register in my main while loop...).
01-22-2018 01:50 AM
Blokk wroteUse a Functional Global Variable to perform Read/Write actions, see snippet below. You can just store the actual cluster state inside this FGV, and when the user selects "cancel" in the corresponding Event case, read out the previous content of the FGV, and use a Local Variable of your cluster in write mode, to revert back to the prev state...
By the way, to use such monstrous cluster seems a bit counter-productive. I would use a 2D array of Boolean+text clusters, much more scaleable and you can easily access array elements. Much better than what you do now... See example here: https://forums.ni.com/t5/LabVIEW/Create-checkboxes-programmatically/td-p/3664192
To add to that idea, the AE/FGV could have an array of clusters internally. That way each change adds to an array and each cancel/undo removes the last element. It'd be a nice feature. 🙂
/Y
01-22-2018 02:12 AM
@Blokk wrote:
u forgot the question was about a "cancel" or "revert back changes" functionality. But using your VI, the OP can easily implement the required option (or using the FGV I showed, or a shift register in my main while loop...)
Yes, I did not quite understand that part. "Previous state" makes sense if this is e.g. a dialog subVI, but I could not tell from the question alone. Yes, for the [cancel] implementation, we would need to store the initial state unless it is all e.g. guaranteed to be all FALSE. Should it otherwise remember the state between calls or is the "Previous state" an input to the dialog?
01-22-2018 02:26 AM
i will be using this VI as a sub vi and it will be used as a popup window. As soon as it pops up based on a decision from the main VI , then ,if i make any changes to the checkboxes , and then if i press cancel button , then those changes must be reverted back. Lets suppose when i called the checkbox window ,there were 2 checkboxes ticked(state 1) , and now i tick 3 more checkboxes(state 2) but press cancel button. On pressing the cancel button, my pop up window must close and any changes made in this call must be reverted back.Now, when i call this pop up window again , then i must see 2 checkboxes selected (state 1), since all the changes made in my last call were reverted back due to pressing of cancel button.
01-22-2018 03:06 AM
That's pretty standard. Just split/remember the incoming cluster, and on cancel you send/rewrite that one.
/Y