Subscribe Bookmark RSS Feed

How can I identify a report in jsl if that report is not associated with a variable?

pcarroll1

Occasional Contributor

Joined:

Aug 11, 2016

               Tables can be referred to in JSL by a variable name or by the title of the table.  For example:

 If I created a table through a query:

               dtMap = Open Database(DSN, sqlStr, "Map");

I can then refer to that table as dtMap or DataTable(“Map”).

If I create a report:

       Biv = Bivariate(Y(yy), X(xx));

I can refer to it as Biv.

But can I call it by a title or name?  (e.g. Report(“Bivariate Fit of yy By xx”))

Normally I prefer to use the variable name,  But I have an application where I don’t have that and need to refer to the report by other means.  

 

1 ACCEPTED SOLUTION

Accepted Solutions
melaniedrake

Staff

Joined:

May 30, 2014

Solution

You can get a list of the window titles as strings directly:

 

Window() << Get Window Title

It returns something like this:

 

{"Script", "Big Class", "Big Class - Distribution"}
9 REPLIES
markbailey

Staff

Joined:

Jun 23, 2011

You can refer to open Bivariate platforms by index using the index syntax, such as Bivariate[1]. The index is the order in which they were launched.

You can use the Window() function to get a list of open windows and then iterate over its items to find and examine all the platforms of a particular type.

Learn it once, use it forever!
pcarroll1

Occasional Contributor

Joined:

Aug 11, 2016

Thanks very much for a quick reply.

 

The output I'm getting from Windows() looks vey generic.   I'm not understanding something.

 

{DisplayBox[HeadBox], DisplayBox[HeadBox], DisplayBox[HeadBox], DisplayBox[HeadBox],

DisplayBox[HeadBox], DisplayBox[HeadBox], DisplayBox[HeadBox], DisplayBox[HeadBox],

DisplayBox[HeadBox], DisplayBox[HeadBox], DisplayBox[HeadBox], DisplayBox[HeadBox]}

 

markbailey

Staff

Joined:

Jun 23, 2011

You must be looking at the results returned by the Window() function in the Log. This display simply verifies that there are a bunch of open windows and identifies the root of each display tree with a generic name.

You can save this list in a variable and then iterate through the list while examining each item. For example, you could obtain the title of the window and check it to see if it is the one that you want. If it is, then you can save it and break out of the loop. Now use the reference obtained this way as if you had saved it in the first place.

Learn it once, use it forever!
melaniedrake

Staff

Joined:

May 30, 2014

Solution

You can get a list of the window titles as strings directly:

 

Window() << Get Window Title

It returns something like this:

 

{"Script", "Big Class", "Big Class - Distribution"}
ian_jmp

Staff

Joined:

Jun 23, 2011

To build on what Mark and Melanie have said already:

NamesDefaultToHere(1);
 // Make a report, but don't keep any reference to it
 dt = Open("$SAMPLE_DATA/Big Class.jmp");
 dt << Bivariate(X(:height), Y(:weight));

// See which windows are open in the current session and find the window of interest
openW = Window();
myWin = {};
for(w=1, w<=NItems(openW), w++,
	winTitle = openW[w] << getWindowTitle;
	Print(winTitle);
	if(Contains(winTitle, "Bivariate"), InsertInto(myWin, openW[w]))
);

// Do a linear fit in each Bivariate report that we found
Wait(2);
for(w=1, w<=NItems(myWin), w++,
	// Get the scriptable object for the Bivariate 'analysis layer'
	thisSO = myWin[w]["Bivariate ?"] << getScriptableObject;
	// Fit the line
	thisSO << fitLine;
);

 

pcarroll1

Occasional Contributor

Joined:

Aug 11, 2016

Thanks everyone. 

Even a variable set as the line below, gives a cryptic output to the user, even if JMP knows what it means.

xxx = Window();

show(xxx);

xxx = {DisplayBox[HeadBox], DisplayBox[HeadBox], DisplayBox[HeadBox], DisplayBox[HeadBox], DisplayBox[HeadBox], DisplayBox[HeadBox]};

 

Either:

xxx << Get Window Title;

Or the one line:

xxx = Window() << Get Window Title;

Works.

pcarroll1

Occasional Contributor

Joined:

Aug 11, 2016

Let me add one compliant for JMP.  Sorry!!

But why does a search in the scripting guide for:

Get Window Title

or

GetWindowTitle

produce no matches?

 

And a search for Window() matches only

Show Window(), Print Window(), New Window() and DataTable Window()?

 

I suggest that these be added somewhere in the early chapters, since they seem to be rather basic functions for managing windows in JMP.

Do you agree?

markbailey

Staff

Joined:

Jun 23, 2011

There is no need to apologize here. (And if there was, then don't post it in the first place! J)

Thank you for submitting that omission in documentation. We will investigate it further.

The message does appear in Help > Scripting Index. The search finds this message and displays information about it. Clicking the Help button opens the documentation for you. In this case, the only information is in the JSL Syntax Guide. There is apparently nothing in the JMP Scripting Guide as you pointed out.

The Scripting Index and the JSL Syntax Guide are not redundant but very useful aids in their own right.

Learn it once, use it forever!
markbailey

Staff

Joined:

Jun 23, 2011

The Window() function is for a script and used by a scripter. The result is not usually visible to the user. The scripter may see the result in the Log as an aid in development and debugging.

The result is useful because it firstly confirms that a result of a list of reference to all the open windows was obtained and it secondly may be used to work with these windows as illustrated by Wendy and Ian. The form "Window() << Get Window Title" uses the result of the function (a list) and distributes the message (Get Window Title) to each item in the list. The result of the message is a new list with title of each open window as a character string. So you don't need to understand the result of Window() ("cryptic output") to use it.

It just depends on what you want to do. If I get the window reference, I can do anything with the window with functions and messages. If I get the window title, which might mean something to the user, that information has somewhat limited usefulness in a script.

Learn it once, use it forever!