I am using the baseball.jmp script to illustrate an issue I am seeing in my own script. The following runs as expected. A single graph builder window is created, and closes after two seconds.
Clear Globals();
Names Default To Here( 1 );
dt = Open( "C:\Program Files\SAS\JMP\14\Samples\Data\Baseball.jmp" );
current data table(dt);
myGraph = Graph Builder(
Size( 531, 448 ),
Show Control Panel( 0 ),
Variables( X( :Player ), Y( :Batting ) ),
Elements( Points( X, Y, Legend( 2 ) ) ),
);
myRep = myGraph << report;
wait(2);
myGraph << close window;
However, I am trying to build up a graph builder expression in a function to make it more flexible. So in the following example, consider myExpr as the constructed expression. Note that the 2 second delays are so I can figure out when the windows get created.
Clear Globals();
Names Default To Here( 1 );
dt = Open( "C:\Program Files\SAS\JMP\14\Samples\Data\Baseball.jmp" );
current data table(dt);
myExpr = expr(Graph Builder(
Size( 531, 448 ),
Show Control Panel( 0 ),
Variables( X( :Player ), Y( :Batting ) ),
Elements( Points( X, Y, Legend( 2 ) ) ),
));
myExpr1 = expr(myGraph = eval expr(myExpr));
eval(myExpr1);
wait(2);
myRep = myGraph << report;
wait(2);
myGraph << close window;
The following happens that does not make sense to me:
- A second and identical graph builder window opens when the report layer is created.
- The myGraph handle that was working when creating the report layer, does not work when running myGraph << close window. This leaves two graph builder windows open.
I am able to close the unexpected second window with myRep << close window, but am not able to close the myGraph window. I am able to manipulate the report layer as usual.
So my questions are:
- Why does a second graph builder window get created?
- Why am I losing the myGraph handle?
Thanks,
Bill