cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Elofar
Level II

JSL - Check box to select variable to then plot in graph builder

Hi everyone,

 

I am trying to make a script which would work this way:

1. Opens a new window showing "Select the parameters you want to plot" with a list of parameters with check box for each, and the operator would chose which ones he wants to plot by ticking them.

2. Then for the ones that are ticked, open a graph builder with the corresponding variables.

 

I am currently able to make the first step (new window and list with check boxes), and I know how to script to create a graph, but I miss the link between them ... I was initially thinking of calling each check box indivudally and then do a succession of "if" like "if cb1 is ticked, then do the graph, if not, then if cb2 is ticked etc ...". I tried the following script to train but it always displays "Failed" in the end no matter if I ticked the box, so it does not really check the box:

 

Names Default To Here( 1 );

New Window( "Choose the parameters to be plotted", 
cb1 = Check Box ("Parameter 1",0),
cb2 = Check Box ("Parameter 2",0)
);

wait(5);

If (cb1 == 1,
Graph Builder(
	Variables(
		X( :Name( "Process duration" ) ),
		Y( :Name( "Parameter 1" ) )	)	),

New Window( "Failed"));

Do you have any idea how to do that?

 

@martindemel 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: JSL - Check box to select variable to then plot in graph builder

The Choose() method that I used is appropriate for Radio Box, but not as useful for the Check Box input case - it only allows one of the statements to be executed.

 

Try something like:

 

		If(cb<<Get(1),
			Graph Builder(Variables(X(:age), Y(:weight))));
		If(cb<<Get(2),
			Graph Builder(Variables(X(:age), Y(:height))));
		If(cb<<Get(3),
			Graph Builder(Variables(X(:age), Y(:sex))));

Note that CheckBox<<Get() takes an argument so that you can get the state of each checkbox - this is different from Radio Box, which only allows one item to be selected.  For more info on the messages that each display box supports, go to:

 

http://www.jmp.com/support/help/en/15.1/#page/jmp/display-functions.shtml#ww2548850

View solution in original post

15 REPLIES 15

Re: JSL - Check box to select variable to then plot in graph builder

When prompting for input in a dialog, here are two common ways to do things:

 

1. Use a modal dialog to pause the execution of the script while waiting for input:

 

Names Default To Here( 1 );
dt=Open("$SAMPLE_DATA/Big Class.jmp");
// Prompt for the input
rc = New Window("Choose the parameters to be plotted",
	<<Modal, <<Return Result,
	rb = Radio Box({"weight", "height"})
);
// Launch report if Ok was pressed if (rc["Button"] == 1, // Ok pressed Choose (rc["rb"], Graph Builder(Variables(X(:age), Y(:weight))), Graph Builder(Variables(X(:age), Y(:height))) ); , // Cancel "Cancel" )

In your script, variable "cb1" is a DisplayBox.  In this example, the <<Return Result option turns all of the display box information into result data.  In a modal dialog the boxes are deleted before execution continues, so this is important!

 

2. Do the "action" part of the dialog as part of a button script:

 

Names Default To Here( 1 );
dt=Open("$SAMPLE_DATA/Big Class.jmp");
// Prompt for the input and create graph
rc = New Window("Choose the parameters to be plotted",
	rb = Radio Box({"weight", "height"}),
	Button Box("Ok",
		Choose(rb<<Get,
			Graph Builder(Variables(X(:age), Y(:weight))),
			Graph Builder(Variables(X(:age), Y(:height)))
		);
		rb<<Close Window;
	)
);

A modal dialog will block all other input to other windows, while the second approach would allow you to continue using other windows in JMP at the same time.

 

Hope that helps!

 

Elofar
Level II

Re: JSL - Check box to select variable to then plot in graph builder

That seems promising thanks a lot !! However in what you suggested, it's either one box or the other but not both, whereas I would like to have as many boxes ticked as required ... What should I change in your scripts? 

Re: JSL - Check box to select variable to then plot in graph builder

In that case you can keep the Check Box() displays that you were originally using - I wasn't clear from your example how the inputs were going to be used if both items (or neither of them) were checked.  RadioBox is a nice control if you want one and only one response, but you can use either of the input methods with any set of controls, including TextEditBox() for string input or NumberEditBox() for numeric input.

Elofar
Level II

Re: JSL - Check box to select variable to then plot in graph builder

I tried to change the radio box into check box in your example, but again it is only doing one single graph even if multiple boxes are selected (and actually it is not working for Height & I have no idea why)... I think I still miss something in that script:

Names Default To Here( 1 );
dt=Open("$SAMPLE_DATA/Big Class.jmp");
rc = New Window("Choose the parameters to be plotted",
	cb = Check box ({"weight", "height", "sex"}),
	Button Box("Ok",
		Choose(cb<<Get,
			Graph Builder(Variables(X(:age), Y(:weight))),
			Graph Builder(Variables(X(:age), Y(:height))),
			Graph Builder(Variables(X(:age), Y(:sex)));
		cb<<Close Window;
	)))

 

 

 

 

Re: JSL - Check box to select variable to then plot in graph builder

The Choose() method that I used is appropriate for Radio Box, but not as useful for the Check Box input case - it only allows one of the statements to be executed.

 

Try something like:

 

		If(cb<<Get(1),
			Graph Builder(Variables(X(:age), Y(:weight))));
		If(cb<<Get(2),
			Graph Builder(Variables(X(:age), Y(:height))));
		If(cb<<Get(3),
			Graph Builder(Variables(X(:age), Y(:sex))));

Note that CheckBox<<Get() takes an argument so that you can get the state of each checkbox - this is different from Radio Box, which only allows one item to be selected.  For more info on the messages that each display box supports, go to:

 

http://www.jmp.com/support/help/en/15.1/#page/jmp/display-functions.shtml#ww2548850

Elofar
Level II

Re: JSL - Check box to select variable to then plot in graph builder

I just tested this solution and it worked perfectly, thank you !!

Re: JSL - Check box to select variable to then plot in graph builder

May not exactly what you need, but if you want to create a Graph for each of the selected variables you might want to consider a Column Dialog to let the operator select the variables he wants to plot in X and Y roles and then plot this for each selected variable:

https://www.jmp.com/support/help/en/15.1/?os=win&source=application#page/jmp/construct-a-column-dial...

Names Default to Here(1);
dt = Open("$SAMPLE_DATA/Tablet Production.jmp", Invisible);
cdb = Column Dialog("Add continuous variables you want to plot against Dissolution" ,
	colxx = ColList( "X", Min Col( 1 ), Modeling Type( "Continuous" ) ),
);
show(cdb);
Eval List(cdb[1::N Items(cdb)-1]);

Graph Builder(
	Size( 526, 454 ),
	Show Control Panel( 0 ),
	Variables( X( colxx[1] ), Y( :Dissolution )),
	Elements( Points( X, Y, Legend( 3 ) ), Line Of Fit( X, Y, Legend( 5 ) ) ),
	Column Switcher( colxx[1], colxx )
);
/****NeverStopLearning****/
Elofar
Level II

Re: JSL - Check box to select variable to then plot in graph builder

Hi Martin,

 

Actually I didn't mentionned the full picture: I already have a script which build all graphes one by one, save them into the journal and then close the graph builder. So at the end of this script, I have a journal with all my graphs.

Now I would like to add a first step to this graph which is the variable selection. So I need that the operator selects what he wants, and then for all the selected variable, the second scrip graph builder -> Journal should applies.

Does that make sense?

 

Re: JSL - Check box to select variable to then plot in graph builder

ok, makes sense. Even then you could use the column dialog, though you then need to slightly adjust your script to have the correct variable name used. The nice thing is you can use a self defined variable name you want to use in your script further on and remuve the dependency on the table variable names. You still can do an if_else structure, but instead of :age you can use your own name which makes the script more general and usually then also more robust.
/****NeverStopLearning****/