大家好,
我想知道是否有一種方法可以判斷您是在處理數據表還是在分析窗口上工作。我想要一個 if 語句,這樣如果您在數據表中,腳本將做一件事,而如果您在分析窗口中,腳本將做另一件事。
感謝您的任何想法!
史蒂夫
您應該能夠使用 Current Window() << 檢查哪個窗口處於活動狀態</CODE><EM>獲取窗口標題</EM>並將其與 Try-structure 一起使用<EM>數據表(參考)<<獲取名稱</EM>(或者<EM>N行(數據表(參考)</EM>例如。</P><P> </P><P>例子:</P><PRE><CODE class=" language-jsl">Names Default To Here(1);
Open("$SAMPLE_DATA/Consumer Preferences.jmp");
wait(2);
curWindow = current window() << Get Window Title; //get window title to curWindow variable
//use Try to check if curWindow is datatable with << Get name or N Rows
Try(
//Show(N Rows(Datatable(curWindow))),
Write(Datatable(curWindow) << Get Name || " --- this is datatable\!N"), //datatable
Write(curWindow || " --- this is not datatable\!N"); //not datatable
);
wait(1);
//create "analysis" which should became active
nw = New Window("Consumer Preferences",
Graph Builder(
Size(495, 450),
Show Control Panel(0),
Variables(X(:Single Status)),
Elements(Points(X, Legend(2)))
);
);
wait(1);
//repeat test used earlier
curWindow = current window() << Get Window Title;
Try(
Write(Datatable(curWindow) << Get Name || " --- this is datatable"), //datatable
Write(curWindow || " --- this is not datatable"); //not datatable
);