# How to get state of checkbox?

Please explain how to get state of checkbox for its usage in further calculations. And I want to keep the selection from session to session without external savings. Thanks in advance

-

You can use DynamicModule.

"Symbols specified in a DynamicModule will by default have their values maintained even across Mathematica sessions." (ref. DynamicModule)

DynamicModule[{x},
If[ValueQ[reportx], x = reportx, reportx = x = False];
Checkbox[Dynamic[x, (reportx = x = #) &]],
Initialization :> (reportx = x)]


The default value of x/reportx is set to False.

It should only be necessary to evaluate the module once; re-evaluation does not reset anything though.

Note that you will need to keep the checkbox output cell in the notebook since the output is where the dynamic value is held. If you delete the output cell and save the notebook the value of x is gone.

There is an interesting Mathgroup post from John Fultz about that here.

-
Recalculation of nb resets value of checkbox –  SergeyFomin Sep 21 '12 at 10:17
Guys from Mars wrote and use this mma, I cant understand anything for two weeks, lets take a pen&paper –  SergeyFomin Sep 21 '12 at 10:56
@ celtschk - I fixed the re-evaluation check. –  Chris Degnen Sep 21 '12 at 11:36
Congratulations!Another pair of shoes!Its necessary to add this example to poor mma documentation –  SergeyFomin Sep 21 '12 at 12:01
The check against True and False can be replaced with checking ValueQ Which is nicer, since it will work for other dynamic values as well as booleans. –  jVincent Sep 21 '12 at 13:20

I find answer in Help system! It's necessary to write

a = DynamicSetting[Checkbox[]] and evaluate it in place by Cntrl+Shft+Enter. Thats all!

-