如何动态创建和处理命名空间?多个 GB 图上的独立句柄。全部,
我无法理解这个问题:
我需要在我的 GB 图上添加句柄。我在一个窗口中有多个 GB 图。句柄脚本中的变量相互干扰。我需要在每个脚本中使用新变量,或者为每个图形脚本创建一个新的命名空间(对我来说似乎是可行的)。但是话说回来,一旦我创建了命名空间,我就通过一个引用变量来访问它——每次我创建新的命名空间时,这个引用变量都会被覆盖。
在下面的例子中,我只是使用了不同的变量名,但它需要动态创建并正确处理。
我记得有一些技巧,例如:
ns = Namespace( Expr( ns << Get Name ) )
但我不确定它是否适用于这种情况,坦率地说,我不确定我是否理解它在我目前使用它的地方是如何工作的以及为什么工作。
以下是一个示例脚本:
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);
自动化和脚本回复:如何动态创建和处理命名空间?多个 GB 图上的独立句柄。我认为你可以跳过命名空间(在这种情况下)并利用上下文框
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);
回复:如何动态创建和处理命名空间?多个 GB 图上的独立句柄。所以,如果我动态创建这些GB并将它们添加到我的Line Up Box中,这个Context Box应该会像函数内部的{Default Local}一样隔离自身内部的变量吗?我试试看。
回复:如何动态创建和处理命名空间?多个 GB 图上的独立句柄。不行,根本没用。手柄不能独立运行。我移动了图 1 上的手柄,但只要点击图 2 上的手柄,它就会跳转到图 1 上手柄的位置。
脚本如下:
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 );
回复:如何动态创建和处理命名空间?多个 GB 图上的独立句柄。比较我们的脚本,您肯定会注意到差异(仅仅拥有上下文框是不够的,您还必须利用它)。
回复:如何动态创建和处理命名空间?多个 GB 图上的独立句柄。哎呀,抱歉……:)我的错:)
如果写得正确,它确实有效。非常感谢!