How to dynamically create and address namespaces? Independent handles on multiple GB plots.All,
I can't wrap my head around this problem:
I need to put handles on my GB plots. I have multiple GB plots in one window. The variables in the handles script cross-talk. I need to either use new variables in each script, or create a new namespace for each graphics script (seems the way to go for me). But then again - as soon as I create a namespace, I address it through a reference variable - which gets overwritten each time I create a new namespace.
In the example below I just use different variable names, but it needs to be created dynamically and addressed properly.
I remember there was some trick using something like:
ns = Namespace( Expr( ns << Get Name ) )
but I'm not sure if it is applicable in this case and to be frankly I'm not sure I understand how and why it's working where I'm currently using it.
Here's an example script:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
lub = Lineup Box( N Col( 2 ) );
ns1 = New Namespace(
"height"
);
ns1:_x_location_ = 2;
ns1:_y_location_ = 50;
lub << Append(Graph Builder(
Size( 528, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 6 ) ) ),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
Handle(
ns1:_x_location_,
ns1:_y_location_,
ns1:_x_location_ = x;
ns1:_y_location_ = y;
)
)}
)
)
);
);
ns2 = New Namespace(
"weight"
);
ns2:_x_location_ = 2;
ns2:_y_location_ = 50;
lub << Append(Graph Builder(
Size( 528, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :weight ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 6 ) ) ),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
Handle(
ns2:_x_location_,
ns2:_y_location_,
ns2:_x_location_ = x;
ns2:_y_location_ = y;
)
)}
)
)
);
);
win = New Window( "Independent Handles Example",lub);
Automation and ScriptingRe: How to dynamically create and address namespaces? Independent handles on multiple GB plots.I think you could just skip namespaces (in this case) and utilize Context Box
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
lub = Lineup Box(N Col(2));
lub << Append(
cb1 = Context Box(
box:_x_location_ = 2;
box:_y_location_ = 50;,
Graph Builder(
Size(528, 450),
Show Control Panel(0),
Variables(X(:age), Y(:height), Overlay(:sex)),
Elements(Points(X, Y, Legend(6))),
SendToReport(
Dispatch({}, "Graph Builder", FrameBox,
{Add Graphics Script(
2,
Description(""),
Handle(
box:_x_location_,
box:_y_location_,
box:_x_location_ = x;
box:_y_location_ = y;
)
)}
)
)
)
)
);
lub << Append(
cb2 = Context Box(
box:_x_location_ = 2;
box:_y_location_ = 50;,
Graph Builder(
Size(528, 450),
Show Control Panel(0),
Variables(X(:age), Y(:weight), Overlay(:sex)),
Elements(Points(X, Y, Legend(6))),
SendToReport(
Dispatch({}, "Graph Builder", FrameBox,
{Add Graphics Script(
2,
Description(""),
Handle(
box:_x_location_,
box:_y_location_,
box:_x_location_ = x;
box:_y_location_ = y;
)
)}
)
)
)
)
);
win = New Window("Independent Handles Example", lub);Re: How to dynamically create and address namespaces? Independent handles on multiple GB plots.So if I'm dynamically creating these GBs and adding them to my Line Up Box, this Context Box should isolate variables inside itself just like {Default Local} does that inside a function? Let me try that.
Re: How to dynamically create and address namespaces? Independent handles on multiple GB plots.Nope, doesn't work. Handles do not behave independently. I move the handle on Plot 1, as soon as I click on Plot 2 handle there jumps to the location where the handle is on Plot 1.
Here's the script:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
lub = Lineup Box( N Col( 2 ) );
lub << Append(
Context Box(
_x_location_ = 2;
_y_location_ = 50;
Graph Builder(
Size( 528, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 6 ) ) ),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
Handle(
_x_location_,
_y_location_,
_x_location_ = x;
_y_location_ = y;
)
)}
)
)
);
)
);
lub << Append(
Context Box(
_x_location_ = 2;
_y_location_ = 50;
Graph Builder(
Size( 528, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :weight ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 6 ) ) ),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
2,
Description( "" ),
Handle(
_x_location_,
_y_location_,
_x_location_ = x;
_y_location_ = y;
)
)}
)
)
);
)
);
win = New Window( "Independent Handles Example", lub );
Re: How to dynamically create and address namespaces? Independent handles on multiple GB plots.Compare our scripts and you will most definitely notice a difference (just having Context Box isn't enough, you also have to utilize it).
Re: How to dynamically create and address namespaces? Independent handles on multiple GB plots.Oops, sorry...
My bad 
When correctly written, it DOES work. Thanks a lot!