cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
miguello
Level VI

Strange behavior - Name of existing constant is unresolved under certain conditions

I have a BorderBox filled with Graph Builder, that I want to save as picture.

I have an "Add Graphics Script" on a FrameBox in it. This script uses variables:

dt << Graph Builder(
					Size( 600, 400 ),
					Show Control Panel( 0 ),
					Show Legend( 0 ),
					Title Alignment( "Right" ),
					Variables( X( :X ), Y( :Y ), Overlay( :Overlay ) ),
					Elements(
						Contour( X, Y, Legend( 5 ), Number of Levels( 18 ), Smoothness( -0.8899 ) ),
						Points( X, Y, Legend( 4 ) )
					),
SendToReport(
Dispatch(
							{},
							"Graph Builder",
							FrameBox,
							{Marker Size( 1 ), Add Graphics Script(
								Transparency( 0.5 );
								Fill Color( "Green" );
								Pen Color( "Dark Green" );
								Line(
									{marginXmin, marginYmin},
									{marginXmin, marginYmax},
									{marginXmax, marginYmax},
									{marginXmax, marginYmin}
									{marginXmin, marginYmin}
								);
							)}
						)

				),

If I open a new window with the BorderBox called "imageForReport" that has this GraphBuilder in it:

window = New Window( "My Report", imageForReport );

and then save the report in the image:

imageForReport << save picture( imgPath, "png" );

everything is fine and everything is working.

But I only need that window to debug on the fly, the final product is the PNG image file.

So for the production version that runs thousands of reports I save on resources and do not open that window.

But in this case the graphic script doesn't work because the first variable (and I guess the rest of them) is not resolved. I get this:

Name Unresolved: marginXmin in access or evaluation of 'marginXmin' , marginXmin/*###*/

in the Log window. How do I fix that without unnecessary opening and closing thousands of windows?

 

UPDATE:

Here's a sample script to test this behavior:

Clear Log();
Clear Symbols();
Clear Globals();
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
cutOutX = 20;
cutOutY = 3;
marginXmin = 70;
marginXmax = 160;
marginYmin = 55;
marginYmax = 65;

imageForReport = Border Box(
	VLBox = V List Box(
		//Zero row
		headerTB = Text Box( "Test savingimage" ),
		gb = Graph Builder(
			Size( 528, 456 ),
			Show Control Panel( 0 ),
			Variables( X( :weight ), Y( :height ) ),
			Elements( Points( X, Y, Legend( 6 ) ) ),
			SendToReport(
				Dispatch(
					{},
					"Graph Builder",
					FrameBox,
					{Marker Size( 1 ), Add Graphics Script(
						Transparency( 0.5 );
						Fill Color( "Green" );
						Pen Color( "Dark Green" );
						Line(
									{marginXmin, marginYmin},
									{marginXmin, (marginYmax - cutOutY)},
									{(marginXmin + cutOutX), (marginYmax - cutOutY)},
									{(marginXmin + cutOutX), marginYmax},
									{(marginXmax - cutOutX), marginYmax},
									{(marginXmax - cutOutX), (marginYmax - cutOutY)},
									{marginXmax, (marginYmax - cutOutY)},
									{marginXmax, marginYmin},
									{marginXmin, marginYmin}
								);
					)}
				)	
		
			)
		)
	)
);


window = New Window( "My Report", imageForReport );	
imageForReport << save picture( "C:\temp\testImage.png", "png" );

If ran as it is - it will open window with the plot and shape in it and it will save PNG image with plot and shape.

If you comment the new window line - it will save plot to PNG image without opening a new window, but the shape will be missing in it.

Can anybody explain it and how to solve it? How to get shape in the saved image without having to open\close new window with the plot?

 

 

3 REPLIES 3
jthi
Super User

Re: Strange behavior - Name of existing constant is unresolved under certain conditions

Is there a reason why you cannot open the window or is the issue just the visibility of window and it popping up?

 

You could hide it with << Show Window(0) and close after saving:

window = New Window( "My Report", << show window(0), imageForReport ); 
window << save picture( "C:\temp\testImage.png", "png" );
window << Close Window;
-Jarmo
miguello
Level VI

Re: Strange behavior - Name of existing constant is unresolved under certain conditions

Yes, there is a reason.

This script runs scheduled and in the background, processing tens of thousands of reports like that, some plots on tables with millions of rows. I noticed that NOT drawing windows saves a LOT of processing time. Plus it's absolutely unnecessary - nobody looks at these thousands of windows popping up several hours straight at night.

 

I suspect that drawing window does something similar to Evaluate() to Display Boxes and without it the variables in Display Boxes are not evaluated. Any way to get a similar effect without actually opening window?

miguello
Level VI

Re: Strange behavior - Name of existing constant is unresolved under certain conditions

Actually, let me test it, maybe NOT showing window as you suggested will also save on processing time