cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
miguello
Level VI

How to work with checkboxes?

In my application on the launch window I have a set of checkboxes. They will define, pretty much, what steps of data cleaning will be performed with the table.

So I need pretty much to get the status of each checkbox and then run a corresponding function on each checkbox that is checked.

Manuals are pretty much useless, the only thing I got was that I can get a list of strings with the names of checkboxes that are selected.

cb << Get Selected()

Is there a snippet that pretty much gets that list and outputs flags (variables that are either 0 or 1 that I can use in IF statements)?

Is there any other way to parse the checkboxes into flags and run corresponding scripts?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: How to work with checkboxes?

This should get you started.

check_list = {"One", "Two", "Three", "Four"};

todo_list  = {};

nw = new window("Checkboxes", << modal(),

     my_cb = checkbox(check_list),

     panelbox("Actions",

           hlistbox(

                button box("OK",

                     keep_going = 1;

                     todo_list = my_cb << get selected;

                ),

                button box("Cancel", keep_going = 0)

           ),

     ),

);

nt = nitems(todo_list);

if (keep_going & nt > 0,

     for (i = 1, i <= nt, i++,

           if (todo_list[i] == "One",

//              Call function for One step

                print("One");

                ,

                todo_list[i] == "Two",

//              Call function for Two step

                print("Two");

                ,

                todo_list[i] == "Three",

//              Call function for Three step

                print("Three");

                ,

                todo_list[i] == "Four",

//              Call function for Two step

                print("Four");

           );

     );

);

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: How to work with checkboxes?

I will point you to:

    Help==>Scripting Index

There, when you scroll down to: 

     CheckBoxBox

and click on it, you will get all of the items that you can ask for, or pass to a check box, along with examples(code snipppets) for each

12985_pastedImage_0.png

Jim
miguello
Level VI

Re: How to work with checkboxes?

Yep, I agree - this was the best place to look.

I ended up implementing it through Get, with only few options that was reasonable enough.

With more options the answer below should work.

The primary reason I was asking was that it is probably the most common way of using checkboxes and I did not want to "invent bicycle", but use the common code snippet to work with checkboxes.

pmroz
Super User

Re: How to work with checkboxes?

This should get you started.

check_list = {"One", "Two", "Three", "Four"};

todo_list  = {};

nw = new window("Checkboxes", << modal(),

     my_cb = checkbox(check_list),

     panelbox("Actions",

           hlistbox(

                button box("OK",

                     keep_going = 1;

                     todo_list = my_cb << get selected;

                ),

                button box("Cancel", keep_going = 0)

           ),

     ),

);

nt = nitems(todo_list);

if (keep_going & nt > 0,

     for (i = 1, i <= nt, i++,

           if (todo_list[i] == "One",

//              Call function for One step

                print("One");

                ,

                todo_list[i] == "Two",

//              Call function for Two step

                print("Two");

                ,

                todo_list[i] == "Three",

//              Call function for Three step

                print("Three");

                ,

                todo_list[i] == "Four",

//              Call function for Two step

                print("Four");

           );

     );

);

miguello
Level VI

Re: How to work with checkboxes?

Thanks a lot!

That, I assume, is the standard way of parsing checkboxes?

pmroz
Super User

Re: How to work with checkboxes?

That's one way of doing it.  It looks like the only way to see what's selected is with

cb << get selected

or

cb << get(index)

The get method requires a bit more work than get selected, which returns all selected values into one list for further processing.