cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
ARETI052
Level III

Check box won't show up in an input prompt input

// New dialog for script selection
scripts = {"Box Plot", "Box Plot_sublot_trend", "Box Plot_duration_trend", "Box Plot_FT1vsFT2", "Tabulation", "CDF&PDF11"};
scriptSelections = J(1, N Items(scripts), 0);

// Initialize the checkboxes array
cb = {};

nw2 = New Window("Script Selection", <<modal,
    <<onClose(
        For(i = 1, i <= N Items(scripts), i++,
            scriptSelections[i] = cb[i] << Get;
        );
    ),
    VListBox(
        Text Box("Select the scripts to run:"),
        Panel Box("Scripts",
            V List Box(
                For(i = 1, i <= N Items(scripts), i++,
                    cb[i] = Check Box(scripts[i], 0);
                )
            )
        ),
        HListBox(
            Button Box("OK", nw2 << Close(1)),
            Spacer Box(size(6, 0)),
            Button Box("Cancel", nw2 << Close(0))
        )
    )
);

if (nw2["Button"] == -1, throw());

selectedScripts = {};

For(i = 1, i <= N Items(scripts), i++,
    If(scriptSelections[i] == 1,
        Insert Into(selectedScripts, scripts[i]);
    );
);

New Window("My report",
    VListBox(
        MyGraph(::yColName, ::xColName, ::xGroupName)
    )
);

// Include selected scripts
For(i = 1, i <= N Items(selectedScripts), i++,
    Include(selectedScripts[i] || ".jsl");
);

So I have several sub scripts for my main script to call, I wanted to create a checkbox where the user can select which sub scripts to run (from Box Plot", "Box Plot_sublot_trend", "Box Plot_duration_trend", "Box Plot_FT1vsFT2", "Tabulation", "CDF&PDF11.) But no matter what I do I only get an empty window with the line " Select Scripts to run".

How can I solve this? Thanks!

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Check box won't show up in an input prompt input

There is no need to use For loop with check boxes. Display Functions (jmp.com) and Construct Display Boxes for New Windows (jmp.com)

 

This might not be exactly correct but gives an idea how to use checkboxes

 

Names Default To Here(1);
// New dialog for script selection
scripts = {"Box Plot", "Box Plot_sublot_trend", "Box Plot_duration_trend", "Box Plot_FT1vsFT2",
"Tabulation", "CDF&PDF11"};
scriptSelections = J(1, N Items(scripts), 0);

// Initialize the checkboxes array
cb = {};

nw2 = New Window("Script Selection",
	<<modal,
	V List Box(
		Text Box("Select the scripts to run:"),
		Panel Box("Scripts",
			cb = Check Box(scripts)
		),
		H List Box(
			Button Box("OK", cb << get selected),
			Spacer Box(size(6, 0)),
			Button Box("Cancel")
		)
	)
);

If(nw2["Button"] == -1,
	Throw()
);

selectedScripts = {};

For(i = 1, i <= N Items(scripts), i++,
	If(scriptSelections[i] == 1,
		Insert Into(selectedScripts, scripts[i])
	)
);

New Window("My report", V List Box(MyGraph(::yColName, ::xColName, ::xGroupName)));

// Include selected scripts
For(i = 1, i <= N Items(selectedScripts), i++,
	Include(selectedScripts[i] || ".jsl")
);

Also do not use << close window on modal window, you will run into all sorts of issues.

 

-Jarmo

View solution in original post

jthi
Super User

Re: Check box won't show up in an input prompt input

As you are using << modal window you have to collect the results before it is closed

 

nw2 = New Window("Script Selection",
	<<modal,
	V List Box(
		Text Box("Select the scripts to run:"),
		Panel Box("Scripts", cb = Check Box(scripts)),
		H List Box(
			Button Box("OK", selectedScripts = cb << get selected),
			Spacer Box(size(6, 0)),
			Button Box("Cancel")
		)
	)
);

and then remove selectedScripts = cb << get selected after the modal. You should also remove all the parts where you are trying to close nw2 as it is already closed when user presses OK/Cancel.

 

Names Default To Here(1);

scripts = {"Box Plot", "Box Plot_sublot_trend", "Box Plot_duration_trend", "Box Plot_FT1vsFT2",
"Tabulation", "CDF&PDF11"};

nw2 = New Window("Script Selection",
	<<modal,
	V List Box(
		Text Box("Select the scripts to run:"),
		Panel Box("Scripts", cb = Check Box(scripts)),
		H List Box(
			Button Box("OK", selectedScripts = cb << get selected),
			Spacer Box(size(6, 0)),
			Button Box("Cancel")
		)
	)
);

If(nw2["Button"] != 1, 
	// Throw("Cancel Pressed");
	stop();
);

// Close the script selection window

// Open a new window for the report
//New Window("My report", V List Box(MyGraph(::yColName, ::xColName, ::xGroupName)));

For Each({scriptname}, selectedScripts,
	script_path = scriptname || ".jsl";
	If(File Exists(script_path),
		Include(script_path)
	,
		Write("\!N", script_path, " doesn't exist!");
	);
);
-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Check box won't show up in an input prompt input

There is no need to use For loop with check boxes. Display Functions (jmp.com) and Construct Display Boxes for New Windows (jmp.com)

 

This might not be exactly correct but gives an idea how to use checkboxes

 

Names Default To Here(1);
// New dialog for script selection
scripts = {"Box Plot", "Box Plot_sublot_trend", "Box Plot_duration_trend", "Box Plot_FT1vsFT2",
"Tabulation", "CDF&PDF11"};
scriptSelections = J(1, N Items(scripts), 0);

// Initialize the checkboxes array
cb = {};

nw2 = New Window("Script Selection",
	<<modal,
	V List Box(
		Text Box("Select the scripts to run:"),
		Panel Box("Scripts",
			cb = Check Box(scripts)
		),
		H List Box(
			Button Box("OK", cb << get selected),
			Spacer Box(size(6, 0)),
			Button Box("Cancel")
		)
	)
);

If(nw2["Button"] == -1,
	Throw()
);

selectedScripts = {};

For(i = 1, i <= N Items(scripts), i++,
	If(scriptSelections[i] == 1,
		Insert Into(selectedScripts, scripts[i])
	)
);

New Window("My report", V List Box(MyGraph(::yColName, ::xColName, ::xGroupName)));

// Include selected scripts
For(i = 1, i <= N Items(selectedScripts), i++,
	Include(selectedScripts[i] || ".jsl")
);

Also do not use << close window on modal window, you will run into all sorts of issues.

 

-Jarmo
ARETI052
Level III

Re: Check box won't show up in an input prompt input

Thanks for the reply, I got that to work, but once I integrated the "<<Get Selected" function to my script, I got the Error "Not a Name" which I can't figure out what's wrong, any suggestions for solving this? Thanks.

// New dialog for script selection
scripts = {"Box Plot", "Box Plot_sublot_trend", "Box Plot_duration_trend", "Box Plot_FT1vsFT2", "Tabulation", "CDF&PDF11"};

// Initialize the checkboxes array
cb = {};

nw2 = New Window("Script Selection",
    <<modal,
    V List Box(
        Text Box("Select the scripts to run:"),
        Panel Box("Scripts",
            cb = Check Box(scripts)
        ),
        H List Box(
            Button Box("OK", Dialog(1)),
            Spacer Box(size(6, 0)),
            Button Box("Cancel", Dialog(0))
        )
    )
);

// Check if the user clicked OK or Cancel
If(nw2["Button"] == 0, // If Cancel button is clicked
    Close(nw2);
    Throw()
);

// Collect the selected scripts based on checkbox input
selectedScripts = cb << get selected;

// Close the script selection window
Close(nw2);

// Open a new window for the report
New Window("My report", V List Box(MyGraph(::yColName, ::xColName, ::xGroupName)));

// Include the selected scripts using if statements
If(Contains(selectedScripts, "Box Plot"),
    Include("Box Plot.jsl");
);

If(Contains(selectedScripts, "Box Plot_sublot_trend"),
    Include("Box Plot_sublot_trend.jsl");
);

If(Contains(selectedScripts, "Box Plot_duration_trend"),
    Include("Box Plot_duration_trend.jsl");
);

If(Contains(selectedScripts, "Box Plot_FT1vsFT2"),
    Include("Box Plot_FT1vsFT2.jsl");
);

If(Contains(selectedScripts, "Tabulation"),
    Include("Tabulation.jsl");
);

If(Contains(selectedScripts, "CDF&PDF11"),
    Include("CDF&PDF11.jsl");
);
jthi
Super User

Re: Check box won't show up in an input prompt input

As you are using << modal window you have to collect the results before it is closed

 

nw2 = New Window("Script Selection",
	<<modal,
	V List Box(
		Text Box("Select the scripts to run:"),
		Panel Box("Scripts", cb = Check Box(scripts)),
		H List Box(
			Button Box("OK", selectedScripts = cb << get selected),
			Spacer Box(size(6, 0)),
			Button Box("Cancel")
		)
	)
);

and then remove selectedScripts = cb << get selected after the modal. You should also remove all the parts where you are trying to close nw2 as it is already closed when user presses OK/Cancel.

 

Names Default To Here(1);

scripts = {"Box Plot", "Box Plot_sublot_trend", "Box Plot_duration_trend", "Box Plot_FT1vsFT2",
"Tabulation", "CDF&PDF11"};

nw2 = New Window("Script Selection",
	<<modal,
	V List Box(
		Text Box("Select the scripts to run:"),
		Panel Box("Scripts", cb = Check Box(scripts)),
		H List Box(
			Button Box("OK", selectedScripts = cb << get selected),
			Spacer Box(size(6, 0)),
			Button Box("Cancel")
		)
	)
);

If(nw2["Button"] != 1, 
	// Throw("Cancel Pressed");
	stop();
);

// Close the script selection window

// Open a new window for the report
//New Window("My report", V List Box(MyGraph(::yColName, ::xColName, ::xGroupName)));

For Each({scriptname}, selectedScripts,
	script_path = scriptname || ".jsl";
	If(File Exists(script_path),
		Include(script_path)
	,
		Write("\!N", script_path, " doesn't exist!");
	);
);
-Jarmo
ARETI052
Level III

Re: Check box won't show up in an input prompt input

Thank you so much!!