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 activeYou should be able to check which window is active with Get Window Title and use that with Try-structure with Datatable(reference) << get name (or N Rows(Datatable(reference) for example.
Example:
Names Default To Here(1);<BR />Open("$SAMPLE_DATA/Consumer Preferences.jmp");<BR />wait(2);<BR />curWindow = current window() << Get Window Title; //get window title to curWindow variable<BR />//use Try to check if curWindow is datatable with << Get name or N Rows<BR />Try(<BR />//Show(N Rows(Datatable(curWindow))),<BR />Write(Datatable(curWindow) << Get Name || " --- this is datatable\!N"), //datatable<BR />Write(curWindow || " --- this is not datatable\!N"); //not datatable<BR />);<BR />wait(1);<BR />//create "analysis" which should became active<BR />nw = New Window("Consumer Preferences",<BR />Graph Builder(<BR />Size(495, 450),<BR />Show Control Panel(0),<BR />Variables(X(:Single Status)),<BR />Elements(Points(X, Legend(2)))<BR />);<BR />);<BR />wait(1);<BR />//repeat test used earlier<BR />curWindow = current window() << Get Window Title;<BR />Try(<BR />Write(Datatable(curWindow) << Get Name || " --- this is datatable"), //datatable<BR />Write(curWindow || " --- this is not datatable"); //not datatable<BR />);
Re: Script to check if a table or analysis is activeThanks for the fast solution!