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
RahBarroso
Level II

JMP Slow Down after On Close with selection window

Hello,

 

I'm trying to prompt users to make a selection of groups from a window that opens at the start of a script that defines an object to be used for the remainder of the script. When the user selects and uses the button box, it works great, but if they close with the window, JMP slows down and  it becomes impossible to edit the script window without right clicking>Stop Script. Does anyone have any ideas on what is missing here?

 

Names Default to Here (1);
groupsel=Expr(
done = 0;//Track if selection made
nwcurr = New Window("Select Group",
    V List Box(
        Text Box("Please select a group:"),
        rb = Radio Box({"A", "B", "C"}),
        Button Box("OK",
            // Set the selected currency based on the user's choice
            group = rb << Get Selected;
            nwcurr << Close Window;  // Close the modal window after selection
            done = 1;  // Mark the selection as done
        )
    )
);

nwcurr << On Close(
        Throw("No selection made. Script stopped."),Stop();
    );
// Wait loop until the selection is made
Wait(0.1);  // Small wait to reduce CPU usage
while(done == 0, Wait(0.1));  // Loop until 'done' is set to 1
);

Eval(groupsel);
4 REPLIES 4
mmarchandFSLR
Level IV

Re: JMP Slow Down after On Close with selection window

Your variable "done" will always be 0, if the window is just closed, so you'll be stuck in the While loop.

mmarchandFSLR
Level IV

Re: JMP Slow Down after On Close with selection window

This may be a good time to use a Modal window.  You won't need the "done" variable.

 

Names Default To Here( 1 );
groupsel = Expr(
	nwcurr = New Window( "Select Group",
		<<Modal,
		V List Box(
			Text Box( "Please select a group:" ),
			rb = Radio Box( {"A", "B", "C"} ),
			Button Box( "OK", 
            // Set the selected currency based on the user's choice
				group = rb << Get Selected
			)
		)
	);
	If( nwcurr == {Button( -1 )},
		Throw( "No selection made." )
	);
);

Eval( groupsel );
jthi
Super User

Re: JMP Slow Down after On Close with selection window

Or other option outside of using modal window, is to move the actions you wish to perform to their own function/expression which will be executed when OK is pressed

Names Default To Here(1);

expr_actions = Expr(
	group = rb << Get Selected;
	show(group);	
);

groupsel = Expr(
	nwcurr = New Window("Select Group",
		V List Box(
			Text Box("Please select a group:"),
			rb = Radio Box({"A", "B", "C"}),
			Button Box("OK", 
				expr_actions;
				nwcurr << Close Window;
			)
		)
	);
);

Eval(groupsel);

Modal is easier, but depending on the use case it will provide worse user-experience (at least in my opinion).

-Jarmo
Craige_Hales
Super User

Re: JMP Slow Down after On Close with selection window

Use one of the previous suggestions. See Modal Dialogs  for examples that might help write a modal solution.

Some of the behavior you are seeing is because of this code:

nwcurr << On Close(
        Throw("No selection made. Script stopped."),Stop();
    );

The OnClose expression needs to evaluate to 0 or 1; 0 (false) means the window should not be allowed to close and 1 (true) means allow the window to finish closing.  I'm not sure what happens with the throw, but probably not anything good; no value is returned. The stop() is never seen by JMP; it appears to be an extra unused parameter. Use a semicolon between statements.

Craige