Script to check if a table or analysis is activeHello everyone,
I was wondering if there is a way to tell if you are working on a data table or working on an analysis window. I'd like to have an if statement so that if you are in a data table the script will do one thing, and if you are in an analysis window the script will do something else.
Thanks for any ideas!
Steve
ScriptingRe: Script to check if a table or analysis is activeThanks for the fast solution!
Re: Script to check if a table or analysis is activeYou should be able to check which window is active with Current Window() <<</CODE><EM>Get Window Title</EM> and use that with Try-structure with <EM>Datatable(reference) << get name</EM> (or <EM>N Rows(Datatable(reference)</EM> for example.</P><P> </P><P>Example:</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
);