cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
AlterEgo
Level II

How to reference outline boxes with the same name, considering their hierarchy?

Hi,

 

I've read the documentation and RTFF-ed but could not find a solution for what I think is a pretty trivial issue. Or maybe I've completely missed it and it's something completely obvious.

 

Let's say I have a report of the following tree structure of outline boxes (in reality e.g. a Fit Least Squares report with multiple responses with more complex structure with additional layers, but this manually created example shows the issue just the same):

New Window("Report",
	Outline Box("Fit Group",
		Outline Box( "Response A",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response B",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response C",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Prediction Profiler" )
	)
);

I want to access the "group" "Prediction Profiler" (the last one).

However, the reference below returns returns the first one (Prediction Profiler of Response A), I assume because it's the first one since they are numbered in order of appearance without consideration of the hierarchy level.

prf = Current Report()[Outline Box("Fit Group")][Outline Box("Prediction Profiler")];

Show( (prf << parent) << get title ) // check the parent - confirmation that it returns the "Response A" profiler 

My current solution is to loop through all of them and check their parent names. The one whose parent name does not start with "Response" is the right one. I have a feeling that this a whole lot of fuss for a very simple task. 

Is there a more elegant, direct way of referencing?

 

Thanks

 

3 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: How to reference outline boxes with the same name, considering their hierarchy?

Xpath or indexing should work

Names Default To Here(1);

nw = New Window("Report",
	Outline Box("Fit Group",
		Outline Box( "Response A",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response B",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response C",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Prediction Profiler" )
	)
);

wait(1);
obs = nw[OutlineBox("Fit Group")] << XPath("//OutlineBox");
Right(obs, 1) << Set Title("This");

wait(1);
nw = New Window("Report",
	Outline Box("Fit Group",
		Outline Box( "Response A",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response B",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response C",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Prediction Profiler" )
	)
);
wait(1);
nw["Fit Group",OutlineBox(8)] << Set Title("That");
-Jarmo

View solution in original post

ErraticAttack
Level VI

Re: How to reference outline boxes with the same name, considering their hierarchy?

You can use XPath() to get all OutlineBoxes -- then you can filter that to outline boxes that have the title "Prediction Profiler" if you want.  Then you can ask each OutlineBox what its parent is, and match that to the top-level OutlineBox "Fit Group".  This will pull the first OutlineBox with title "Prediction Profiler" that is a direct child of the OutlineBox( "Fit Group" ).

 

win = New Window("Report",
	Outline Box("Fit Group",
		Outline Box( "Response A",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response B",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response C",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Prediction Profiler" )
	)
);

olb = win[Outline Box( "Fit Group" )];            // top-level OLB of interest

olbs = olb << XPath( "//OutlineBox" );            // ALL child OLBs, regardless of hierarchy
titles = olbs << Get Title;                       // Get the titles of each OLB
profilers = Loc( titles, "Prediction Profiler" ); // Find the OLB locations in the list with title "Prediction Profiler"
profiler olbs = olbs[profilers];                  // Get the list of OLBs with title "Prediction Profiler"

direct child profiler loc = Contains( profiler olbs << Parent, olb ); // Location of OLBs that have the "Fit Group" OLB as the direct parent

profiler = profiler olbs[direct child profiler loc]; // First of the above list

Wait( 2 );
profiler << Set Title( "Gotcha!!" ) // change name to show that the correct OLB is referenced

Jordan

View solution in original post

Re: How to reference outline boxes with the same name, considering their hierarchy?

You can use the XPath language to get specific objects in the XML tree.

 

Names Default to Here( 1 );

// set up example
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
obj = dt << Fit Group(
	Fit Model(
		Y( :height ),
		Effects( :age, :sex ),
		Personality( "Standard Least Squares" ),
		Emphasis( "Minimal Report" ),
		Run(
			Profiler(
				1,
				Confidence Intervals( 1 ),
				Term Value(
					age( 12, Lock( 0 ), Show( 1 ) ),
					sex( "F", Lock( 0 ), Show( 1 ) )
				)
			),
			:height << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
			Parameter Estimates( 1 ), Scaled Estimates( 0 ),
			Plot Actual by Predicted( 0 ), Plot Regression( 0 ),
			Plot Residual by Predicted( 0 ), Plot Studentized Residuals( 0 ),
			Plot Effect Leverage( 0 ), Plot Residual by Normal Quantiles( 0 ),
			Box Cox Y Transformation( 0 )}
		)
	),
	Fit Model(
		Y( :weight ),
		Effects( :age, :sex ),
		Personality( "Standard Least Squares" ),
		Emphasis( "Minimal Report" ),
		Run(
			Profiler(
				1,
				Confidence Intervals( 1 ),
				Term Value(
					age( 12, Lock( 0 ), Show( 1 ) ),
					sex( "F", Lock( 0 ), Show( 1 ) )
				)
			),
			:weight << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
			Parameter Estimates( 1 ), Scaled Estimates( 0 ),
			Plot Actual by Predicted( 0 ), Plot Regression( 0 ),
			Plot Residual by Predicted( 0 ), Plot Studentized Residuals( 0 ),
			Plot Effect Leverage( 0 ), Plot Residual by Normal Quantiles( 0 ),
			Box Cox Y Transformation( 0 )}
		)
	),
	<<{Profiler(
		1,
		Confidence Intervals( 1 ),
		Term Value(
			age( 12, Lock( 0 ), Show( 1 ) ),
			sex( "F", Lock( 0 ), Show( 1 ) )
		)
	)}
);

// start to change title
rpt = obj << Report;
profiler = rpt << XPath( "//OutlineBox[text()='Prediction Profiler']" );
last = N Items( profiler );
profiler[last] << Set Title( "I'm here!" );

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: How to reference outline boxes with the same name, considering their hierarchy?

If you know the exact order of the Outline Boxes, you can use the following

prf = Current Report()["Fit Group",OutlineBox(3)]<<set title("xx");

or

prf = Current Report()["Fit Group","Response A","Prediction Profiler"]<<set title("xx");
Jim
AlterEgo
Level II

Re: How to reference outline boxes with the same name, considering their hierarchy?

Your suggestion would work if I wanted to drill down to the individual response profiler since I know that there is only one under each response outline box. Then I could include into the reference the exact path down to the outline box of interest. 

 

However, I specifically want to access the "group" profiler, which happens to be the highest one hierarchy-wise, i.e. directly under the "Fit Group" outline box not a level lower, under the individual response outline box. 

The problem is I don't know the exact order, it's always different. Not just the number of the response outline boxes but also the presence of individual response profilers and/or other other outline boxes within them may vary, so I cannot reference it by number. Unfortunately, it seems that the reference syntax does not consider hierarchy but only over-all order of appearance.

 

And although my profiler of interest also happens to be the last one by order of appearance, this doesn't help me much either since I don't know their number without looping through them, which I'm already doing.

jthi
Super User

Re: How to reference outline boxes with the same name, considering their hierarchy?

Xpath or indexing should work

Names Default To Here(1);

nw = New Window("Report",
	Outline Box("Fit Group",
		Outline Box( "Response A",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response B",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response C",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Prediction Profiler" )
	)
);

wait(1);
obs = nw[OutlineBox("Fit Group")] << XPath("//OutlineBox");
Right(obs, 1) << Set Title("This");

wait(1);
nw = New Window("Report",
	Outline Box("Fit Group",
		Outline Box( "Response A",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response B",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response C",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Prediction Profiler" )
	)
);
wait(1);
nw["Fit Group",OutlineBox(8)] << Set Title("That");
-Jarmo
ErraticAttack
Level VI

Re: How to reference outline boxes with the same name, considering their hierarchy?

You can use XPath() to get all OutlineBoxes -- then you can filter that to outline boxes that have the title "Prediction Profiler" if you want.  Then you can ask each OutlineBox what its parent is, and match that to the top-level OutlineBox "Fit Group".  This will pull the first OutlineBox with title "Prediction Profiler" that is a direct child of the OutlineBox( "Fit Group" ).

 

win = New Window("Report",
	Outline Box("Fit Group",
		Outline Box( "Response A",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response B",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Response C",
			Outline Box("Prediction Profiler")
		),
		Outline Box( "Prediction Profiler" )
	)
);

olb = win[Outline Box( "Fit Group" )];            // top-level OLB of interest

olbs = olb << XPath( "//OutlineBox" );            // ALL child OLBs, regardless of hierarchy
titles = olbs << Get Title;                       // Get the titles of each OLB
profilers = Loc( titles, "Prediction Profiler" ); // Find the OLB locations in the list with title "Prediction Profiler"
profiler olbs = olbs[profilers];                  // Get the list of OLBs with title "Prediction Profiler"

direct child profiler loc = Contains( profiler olbs << Parent, olb ); // Location of OLBs that have the "Fit Group" OLB as the direct parent

profiler = profiler olbs[direct child profiler loc]; // First of the above list

Wait( 2 );
profiler << Set Title( "Gotcha!!" ) // change name to show that the correct OLB is referenced

Jordan

Re: How to reference outline boxes with the same name, considering their hierarchy?

You can use the XPath language to get specific objects in the XML tree.

 

Names Default to Here( 1 );

// set up example
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
obj = dt << Fit Group(
	Fit Model(
		Y( :height ),
		Effects( :age, :sex ),
		Personality( "Standard Least Squares" ),
		Emphasis( "Minimal Report" ),
		Run(
			Profiler(
				1,
				Confidence Intervals( 1 ),
				Term Value(
					age( 12, Lock( 0 ), Show( 1 ) ),
					sex( "F", Lock( 0 ), Show( 1 ) )
				)
			),
			:height << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
			Parameter Estimates( 1 ), Scaled Estimates( 0 ),
			Plot Actual by Predicted( 0 ), Plot Regression( 0 ),
			Plot Residual by Predicted( 0 ), Plot Studentized Residuals( 0 ),
			Plot Effect Leverage( 0 ), Plot Residual by Normal Quantiles( 0 ),
			Box Cox Y Transformation( 0 )}
		)
	),
	Fit Model(
		Y( :weight ),
		Effects( :age, :sex ),
		Personality( "Standard Least Squares" ),
		Emphasis( "Minimal Report" ),
		Run(
			Profiler(
				1,
				Confidence Intervals( 1 ),
				Term Value(
					age( 12, Lock( 0 ), Show( 1 ) ),
					sex( "F", Lock( 0 ), Show( 1 ) )
				)
			),
			:weight << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
			Parameter Estimates( 1 ), Scaled Estimates( 0 ),
			Plot Actual by Predicted( 0 ), Plot Regression( 0 ),
			Plot Residual by Predicted( 0 ), Plot Studentized Residuals( 0 ),
			Plot Effect Leverage( 0 ), Plot Residual by Normal Quantiles( 0 ),
			Box Cox Y Transformation( 0 )}
		)
	),
	<<{Profiler(
		1,
		Confidence Intervals( 1 ),
		Term Value(
			age( 12, Lock( 0 ), Show( 1 ) ),
			sex( "F", Lock( 0 ), Show( 1 ) )
		)
	)}
);

// start to change title
rpt = obj << Report;
profiler = rpt << XPath( "//OutlineBox[text()='Prediction Profiler']" );
last = N Items( profiler );
profiler[last] << Set Title( "I'm here!" );
AlterEgo
Level II

Re: How to reference outline boxes with the same name, considering their hierarchy?

Thank you all!

 

Definitely better than looping.

DaveB
Staff

Re: How to reference outline boxes with the same name, considering their hierarchy?

Here is a pretty literal translation of the original search algorithm into xpath that works with Mark's example

 

pp =(rpt << xpath("//OutlineBox[text()='Prediction Profiler'][count(./ancestor::OutlineBox[contains(text(),'Response')])=0]"));
pp << Set Title("I'm here");

It searches from the top of the display tree for an OutlineBox with a title of "Predicted Profiler" that also has 0 OutlineBoxes above that have titles that include the word "Response".   It is also worth pointing out that in Jmp 17 there is a new control in the properties panel that will give you the window subscript or xpath snippet to any display box.  The snippet it gives you won't be as flexible as some of the solutions posted here, but it will be a good starting point

DaveB_0-1677801812645.png

 

AlterEgo
Level II

Re: How to reference outline boxes with the same name, considering their hierarchy?

deleted - wrong post