如何動態建立和處理命名空間?多個 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 圖上的獨立句柄。哎呀,抱歉…:)我的錯:)
如果寫得正確,它確實有效。非常感謝!