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
msharp
Super User (Alumni)

Keep Dialog Window Open?

Anyone have a quick code to mimic the "Keep dialog open" option you see in the table platforms, like 'subset'.  If yes, does it work with a Modal window?

10529_pastedImage_0.png

11 REPLIES 11
Kevin_Anderson
Level VI

Re: Keep Dialog Window Open?

From the Scripting Index:

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );

obj = Fit Model(

  Y( :ABRASION ),

  Effects( :SILICA, :SILANE ),

  Personality( Standard Least Squares )

);

obj << Keep Dialog Open( 1 );

obj << Run;

ron_horne
Super User (Alumni)

Re: Keep Dialog Window Open?

Hi msharp,

I found these two conflicting links on the topic:

This one (Page 83) says it is not very useful:

https://books.google.co.uk/books?id=42Bt1lDZLYoC&pg=PA82&lpg=PA82&dq=jsl+keep+dialog+open&source=bl&...

this one shows some use of “Keep dialog open (1)” but I am not sure it is the way you are looking for:

http://www.jmp.com/support/help/Utility_Functions.shtml

best,

ron

hlrauch
Level III

Re: Keep Dialog Window Open?

msharp,

It sounds like you want to add the "Keep Dialog Open" as a check box in the dialog window, right? If that's the case, here's part of a script that I've used to add one or more columns of random numbers. The script behind the "OK" button closes the window only if the check box is unchecked.

Names Default to Here( 1 );

keepopen = 0;

New Window( "Example", Show Menu( 0 ), Show Toolbars( 0 ), Suppress Autohide,

  Text Box( "Example: Keep Dialog Open Checkbox" ),

  Text Box( "" ),

  H List Box(

    keepcbox = Check Box( "Keep dialog open", keepopen = keepcbox << get( 1 ) ),

    Button Box( "OK",

      // Insert name of an expression to run as a script

      If( !keepopen, Current Window() << Close Window);

    ),

    Button Box( "Cancel",

      Current Window() << Close Window

    )

  )

);

Of course you would want to add more options to the dialog window (advanced example in the JMP Scripting Guide; pages 454-456). I don't think that you can add a similar check box using the older (modal) Column Dialog() method. You can make the above window modal by adding a <<Modal option, but that may require some additional tricks.


Howard

msharp
Super User (Alumni)

Re: Keep Dialog Window Open?

This is what I'm looking for, I just need it to work with a Modal Window since I want to force the user to respond.  Any thoughts?

msharp
Super User (Alumni)

Re: Keep Dialog Window Open?

Actually I figured it out:

'<<Modal, <<On Close(0)'

This is bad b/c you'll end up with a window that is modal and won't close, but appending it to hlrauch's script:

Names Default to Here( 1 ); 

keepopen = 0; 

 

New Window( "Example", Show Menu( 0 ), Show Toolbars( 0 ), Suppress Autohide, 

  <<Modal,

  Text Box( "Example: Keep Dialog Open Checkbox" ), 

  Text Box( "" ), 

  H List Box(

    keepcbox = Check Box( "Keep dialog open", keepopen = keepcbox << get( 1 ) ), 

    Button Box( "OK", 

 

      // Insert name of an expression to run as a script 

 

      If( !keepopen, Current Window() << On Close(1), Current Window() << On Close(0)); 

    ), 

    Button Box( "Cancel", 

      Current Window() << Close Window 

    )

  )

); 

msharp
Super User (Alumni)

Re: Keep Dialog Window Open?

Just another note, having issues with 'Current Window()' if the expression that is run creates windows.  Switched it to keepcbox (or any other display in the modal window) and it should be fixed.

ms
Super User (Alumni) ms
Super User (Alumni)

Re: Keep Dialog Window Open?

I am not sure what On Close(1) and On Close(0) are suposed to do here.

However, this does not work well in JMP 12.1 for Mac. If "Keep dialog open" is checked and I click "OK" an empty (non-modal) window is left behind without any obvious method to close it. And if I select "Close" in the menu JMP crash. Weird


msharp
Super User (Alumni)

Re: Keep Dialog Window Open?

From the Scripting Index- under New Window:

"If the Modal argument is specified, the new window is created as a modal window.  On Open, On Close, On Validate, and Return Result are available only for modal windows.  On Open() evaluates its expression when the window is created. If On Close() returns zero, the window is prevented from closing."

I'm not sure why it isn't working on your Mac, but my guess is you didn't make the update on Current Window().

hlrauch
Level III

Re: Keep Dialog Window Open?

I agree with MS: I'm not sure what the << On Close() function is doing either. The JSL Syntax Reference (under Help > Books) explains the On Close function differently than the Scripting Index. From the Scripting Reference: "<<On Close (expr) runs expr when the window is closed. Returns 0 if the window fails to close." So does an argument of 0 prevent the window from closing or does a window failing to close generate a 0 result from the function? Very confusing.

Getting back to the issue of your modal dialog box... I think that the << Modal command treats the "OK" and "Cancel" buttons as special buttons (same behavior as old Dialog() function). So scripts can not be attached to the "OK" and "Cancel" buttons (an error appears in the log).

So here's another approach that may work for your modal window. Create other buttons that can perform actions by attaching scripts to those buttons. The window stays open until the "OK" button is clicked. Unfortunately I don't think that you can rename the "OK" button to "Close" or allow another button to close the modal window.

Names Default To Here( 1 );

win = New Window( "Example",

  << Modal,

  << On Close ( Print( "Closed" ) ), // prints to log window

  Show Menu( 0 ), Show Toolbars( 0 ), Suppress Autohide,

  Text Box( "Example: Modal Dialog Window" ),

  Text Box( "" ),

  H List Box(

    Button Box( "Say Hello", Print( "Hello" ) ), // prints to log window

    Button Box( "New Window", newwin = New Window( "New Window" ) ),

    Button Box( "OK" )

  )

);

I have included an example of << On Close() in this script. You can see that it performs this script action when the window is closed.

Good luck!

Howard