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
pen51
Level I

JMP window not closing

I'm working on a script that just does basic image editing. I have my image in one window, then clicking an "Image Options" window opens up a window with sliders for contrast and brightness. Whenever I close the image options window, it never actually closes, the window is just hidden. Hitting the "x" in the corner does nothing. I even added a "Close" button that just says << Close Window, but then it just hides it. In order to get it to close, I have to close JMP completely. Is there something I'm missing?

Names Default To Here( 1 );
img = Open( "$SAMPLE_IMAGES/windmap.png", "png" );
orig = New Image( img );
wind = New Image( orig );
slbval = 1;
slbval1 = 1;
w = New Window( "View Image",
	vlb = V List Box(
		Graph Box(
			FrameSize( 500, 500 ),
			X Scale( 0, 100 ),
			Y Scale( 0, 100 ),
			<<Add Image( image( wind ), bounds( top( 90 ), Left( 10 ), bottom( 10 ), Right( 90 ) ) )
		),
		Button Box( "Open options",
			options;
			optionswindowopen = 1;
		)
	)
);

refilter = Expr(
	wind << Set Pixels( orig << Get Pixels );
	wind << Filter( "Contrast", slbval );
	wind << Filter( "Gamma", slbval1 );
);
refilter;
optionswindowopen = 0;

options = Expr(
	imgop = New Window( "Image Options", 
		<<On Close(
			optionswindowopen = 0;
		),
		V List Box(
			tb = Text Box( "Contrast: " || Char( slbval ) ),
			Slider Box(
				0.01,
				15,
				slbval,
				tb << Set Text( "Contrast: " || Char( slbval ) );
				refilter;
				vlb << reshow;
			),
			tb1 = Text Box( "Brightness: " || Char( slbval1 ) ),
			Slider Box(
				0.01,
				5,
				slbval1,
				tb1 << Set Text( "Brightness: " || Char( slbval1 ) );
				refilter;
				vlb << reshow;
			),
			Button Box("Close",
				imgop << Close Window;
			)
		)
	)
);
 
2 ACCEPTED SOLUTIONS

Accepted Solutions
stan_koprowski
Community Manager Community Manager

Re: JMP window not closing

Hi @pen51,

The issue with the script is on line 32:

<<On Close( optionswindowopen = 0 );

 

The window will never close when set to 0.

If you change to 

<<On Close( optionswindowopen = 1 );

It closes as expected.

According to the scripting index if the << On Close() returns zero (0) the window is prevented from closing.

<<On Close<<On Close

cheers,

Stan

View solution in original post

Jeff_Perkinson
Community Manager Community Manager

Re: JMP window not closing

@stan_koprowski has pointed you in the right direction and you ask a good question and the answer points to a subtlety of JSL.

 

The key is to remember that everything in JSL is a function, even operators like = which is equivalent to the Assign() function. Since everything is a function, they all return something. The Assign() function returns the value being assigned.

 

So, because your OnClose() argument is an Assign() function that assigns 0, and because the Assign() function returns the value being assigned it returns 0, and because On Close() says that the window won't close if the function being called returns 0 the window will never close.

 

However, since everything is a function, the ; operator is actually the Glue() function. The Glue() function returns the result of it's last argument. So, you can workaround this by doing anything else in your On Close() script after the assignment, like just putting a 1.

 

So, this will work for you:

imgop = New Window( "Image Options", 
		<<On Close(
			optionswindowopen = 0;
                        1;
		),

 

-Jeff

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: JMP window not closing

This is very curious.....I played around with it, and could not find any consistant reason for the options window being able to be closed.  In fact, under JMP 14, my JMP session would not close.  I had to force an operating system close.

 

This needs to be sent to the JMP support folks....

     support@jmp.com

Jim
cwillden
Super User (Alumni)

Re: JMP window not closing

lol, I had the same happen in JMP 13.  Thanks @pen51 for infecting our computers as well with your strange unintentional virus (j/k).

-- Cameron Willden
pen51
Level I

Re: JMP window not closing

I've been in contact with JMP support, but the technician I talked to could not replicate the problem with the same script. I'm running JMP 13.1, @cwillden what are you running? I'll try to update and see if it works, but hopes are not high since @txnelson also had this problem in JMP 14. 

uday_guntupalli
Level VIII

Re: JMP window not closing

@pen51,
         I tested this script on JMP 13.1.0 and had the same issue. 

Best
Uday
stan_koprowski
Community Manager Community Manager

Re: JMP window not closing

Hi @pen51,

The issue with the script is on line 32:

<<On Close( optionswindowopen = 0 );

 

The window will never close when set to 0.

If you change to 

<<On Close( optionswindowopen = 1 );

It closes as expected.

According to the scripting index if the << On Close() returns zero (0) the window is prevented from closing.

<<On Close<<On Close

cheers,

Stan

pen51
Level I

Re: JMP window not closing

Hi Stan, the optionswindowopen is just a boolean to say whether or not the window is open. Since I'm closing the window, on On Close would set the boolean to 0. If the window is open, the boolean is 1. I would like to keep this boolean with this logic, so do you have a work around?

Jeff_Perkinson
Community Manager Community Manager

Re: JMP window not closing

@stan_koprowski has pointed you in the right direction and you ask a good question and the answer points to a subtlety of JSL.

 

The key is to remember that everything in JSL is a function, even operators like = which is equivalent to the Assign() function. Since everything is a function, they all return something. The Assign() function returns the value being assigned.

 

So, because your OnClose() argument is an Assign() function that assigns 0, and because the Assign() function returns the value being assigned it returns 0, and because On Close() says that the window won't close if the function being called returns 0 the window will never close.

 

However, since everything is a function, the ; operator is actually the Glue() function. The Glue() function returns the result of it's last argument. So, you can workaround this by doing anything else in your On Close() script after the assignment, like just putting a 1.

 

So, this will work for you:

imgop = New Window( "Image Options", 
		<<On Close(
			optionswindowopen = 0;
                        1;
		),

 

-Jeff
stan_koprowski
Community Manager Community Manager

Re: JMP window not closing

Hi @pen51,

You could add 1 to the On Close argument.

<< On Close ( optionswindowopen = 0; 1)

This way it will return the result of the last argument; in this case 1.

cheers,

Stan