cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
View Original Published Thread

Extracting data from outline boxes through a loop in journal

Juli
Level III

Hi all,

 

I am trying to make a script that will print data for me. I have a journal, where I want to print data for each of the Outline boxes (please see journal data.jrn).

I am aware I am missing quite a bit to reach the data table I wish, but I have come across the first hurdle and that is it only prints for 1 outline box and not all. See my script below:

 

 

// JMP version 16sd = currentdatatable();rpt = Current Journal();

// Get the number of outline boxes
numOutlineBoxes = nitems(rpt);

int = rep = sumfit = sumfitLL = sumfitUL = {};
sum = 0;


// Loop through each outline box
for (i = 1, i <= numOutlineBoxes, i++,
    outlineBox = rpt[i];
    
    sumfit = outlineBox[Outline Box( numOutlineBoxes )][Number Col Box( 1 )] << Get as Matrix;
    
	sumfitLL = outlineBox[Outline Box( numOutlineBoxes )][Number Col Box( 3 )] << Get as Matrix;
	sumfitUL = outlineBox[Outline Box( numOutlineBoxes )][Number Col Box( 4 )] << Get as Matrix;

	sumfit_rep = Round( sumfit[2] , 3 );
	sumfit_int = Round( sumfit[3] , 3 );
	lowerCL_rep = Round( sumfitLL[2] , 3 );
	upperCL_rep = Round( sumfitUL[2] , 3 );
	lowerCL_int = Round( sumfitLL[3] , 3 );
	upperCL_int = Round( sumfitUL[3] , 3 );
	
	Insert Into( rep, Char( sumfit_rep ) || " [" || Char( lowerCL_rep ) || " ; " || Char( upperCL_rep ) || "]" );
	Insert Into( int, Char ( sumfit_int ) || " [" || Char( lowerCL_int ) || " ; " || Char( upperCL_int ) || "]" );
	
	// Get By Group column
	//whereCol = Word( 2, ((rep << parent)[Text Box( 1 )]) << get text, ":=)" );
		
	term = outlineBox[Outline Box( numOutlineBoxes )][String Col Box( 1 )] << Get();
    
    sum = sum + 1
);


// Create the table
dlg = New Window( "Custom Report",
	Outline Box( "Selected Values",
		Lineup Box( N Col( 2 ), Text Box( "Factor of Interest: " ), Text Box( term[1] ) ),
		Spacer Box( size( 0, 10 ) ),
		tb = Table Box(
			String Col Box( "Paramenter", testvalue ),
			//String Col Box( whereCol, repeat(ByGroups, sum) ),
			String Col Box( "Repeatability, " || term[1], rep ),
			String Col Box( "Intermediate precision, " || term[2], int ),
		)
	)
);

tb << Set Shade Headings( 0 ); // Turn off shaded table headings.
tb << Set Column Borders( 1 ); // Turn off table column borders.
tb << Set row Borders( 1 );
tb << border( 1 );

The print looks as follows:

 

Juli_0-1737988467054.png

 

At the final stage, I would like the pint to look as follows:

Juli_2-1737988885926.png

 

To sum up, I have the following steps that need to be fixed: 

 

1. Get the loop to work so that all Outline boxes are taken into account

2. Get it to include parameter and batch

3. Get it to dividedly print repeatability and intermediate with the laboratory AA/BB

 

I hope you can help me with this. 

 

Best regards,

Julie

 

 

Best regards,
Julie
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User


Re: Extracting data from outline boxes through a loop in journal

majorrptList = rpt << xpath( "//OutlineBox[contains(text(),'Standard Deviations')]" );

returns a list of the pointers to all of the different Outline Boxes in your journal, that have the title "Standard Deviations".

The returned list is:

{DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[
OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox],
DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[
OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox],
DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[
OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox]}

If you want a count of the number of the Outline Boxes, you would need to do something like

numOutlineBoxes = N Items( rpt << xpath( "//OutlineBox[contains(text(),'Standard Deviations')]" ));

Looking at the remainder of your JSL, it appears that you are confused with how to deal with the 20 different Standard Deviation Table Boxes.  You seem to want to take the count of the number of Standard Deviation Outline Boxes and somehow retrieve all of the data from all of the 20 Table Boxes all at once.  Your syntax is also incorrect, and returns an error message.  What I believe you want is:

sumFit = majorrptList[1][Number Col Box( 1 )] << Get as Matrix;

Which returns 

[3.67530167633204, 3.67530167633204, 7.01812976988444]

Which comes from the 1st Standard Deviation Outline Box in your journal

txnelson_0-1738077503661.png

You seem to want to use numOutlineBoxes in your reference, in an attempt to somehow get all of the data from all of the Table Boxes.  However, since the value of numOutlineBoxes is 20, what running

numOutlineBoxes = N Items( rpt << xpath( "//OutlineBox[contains(text(),'Standard Deviations')]" ));
sumFit = majorrptList[numOutlineBoxes][Number Col Box( 1 )] << Get as Matrix;

what you get is 

[0.00401248052954899, 0.00401248052954899, 0.0399901237806931]

which are the values from the 20th Standard Deviations Outline Box

txnelson_1-1738077940567.png

It appears that you are attempting to run before learning to walk.  I suggest you slow down and take the time to read though the Scripting Guide to gain a better understanding of JSL before you take on such a large project.

Jim

View solution in original post

6 REPLIES 6
jthi
Super User


Re: Extracting data from outline boxes through a loop in journal

Is there some specific reason for using Journal instead of accessing the report before it is made into a journal? Also have you tried building the report from the tables you can get using Make Combined Data Table?

jthi_0-1737989583163.png

jthi_1-1737989590210.png

-Jarmo
jthi
Super User


Re: Extracting data from outline boxes through a loop in journal

And then if you have enough patience (I don't with Tabulate...) you might be able to create quite OK report using tabulate

jthi_0-1737990769686.png

 

jthi_2-1737990975753.png

jthi_3-1737991045233.png

This requires JMP17 or JMP18 (packing)

jthi_4-1737991054731.png

 

-Jarmo
Juli
Level III


Re: Extracting data from outline boxes through a loop in journal

Hi Jthi,

 

Thank you for your reply. The reason why journal is used instead of report is because I cannot save the report where it still contains the standard deviation outline box. Therefore, I had to save it to a journal. 

 

I will try to look into this option about making it into a combined table. 

 

Best regards,

Julie 

Best regards,
Julie
txnelson
Super User


Re: Extracting data from outline boxes through a loop in journal

Given that your Journal is referenced as

rpt = Current Journal();

and you are using

// Get the number of outline boxes
numOutlineBoxes = nitems(rpt);

to get the number of OutlineBoxes, it will always return 1.  You should be using Xpath() to return a list of all of the OutlineBoxes.

numOutlineBoxes = nitems(rpt << xpath( "//OutlineBox" )) ;

however it will find 60 outline boxes.  So to narrow this down, you can get a list of the primary headers with

majorrptList= rpt << xpath( "//OutlineBox[contains(text(),'Variability Gauge')]" ) 

That will give you pointers to each of your By groups output

 

Jim
Juli
Level III


Re: Extracting data from outline boxes through a loop in journal

Hi Jim,

 

Thank you for your reply. I have tried this, where I added changed from numOutlineBoxes to:

 

majorrptList = rpt << xpath( "//OutlineBox[contains(text(),'Standard Deviations')]" );

 

 

The script saves information to sumfit_rep and sumfit_int, but it does not save to lowerCL_rep upperCL_rep lowerCL_int or upperCL_int  during the part below:

 

 

	sumfit = outlineBox[Outline Box( majorrptList )][Number Col Box( 1 )] << Get as Matrix;
    
	sumfitLL = outlineBox[Outline Box( majorrptList )][Number Col Box( 3 )] << Get as Matrix;
	sumfitUL = outlineBox[Outline Box( majorrptList )][Number Col Box( 4 )] << Get as Matrix;

	sumfit_rep = Round( sumfit[2] , 3 );
	sumfit_int = Round( sumfit[3] , 3 );
	lowerCL_rep = Round( sumfitLL[2] , 3 );
	upperCL_rep = Round( sumfitUL[2] , 3 );
	lowerCL_int = Round( sumfitLL[3] , 3 );
	upperCL_int = Round( sumfitUL[3] , 3 );
	
	Insert Into( rep, Char( sumfit_rep ) || " [" || Char( lowerCL_rep ) || " ; " || Char( upperCL_rep ) || "]" );
	Insert Into( int, Char ( sumfit_int ) || " [" || Char( lowerCL_int ) || " ; " || Char( upperCL_int ) || "]" );

 

As I am not sure how to go from here to get the table I want with information about sample/batch and parameter, I have tried to make a combined table and then extract it from there, but it does something crazy and I am highly confused. I have attached the combined table (combined data table for int rep test script) and the script (int rep test script with combined table). I hope you will take a look and see if you can find the reason for chaos  

 

Best regards,
Julie
txnelson
Super User


Re: Extracting data from outline boxes through a loop in journal

majorrptList = rpt << xpath( "//OutlineBox[contains(text(),'Standard Deviations')]" );

returns a list of the pointers to all of the different Outline Boxes in your journal, that have the title "Standard Deviations".

The returned list is:

{DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[
OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox],
DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[
OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox],
DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox], DisplayBox[
OutlineBox], DisplayBox[OutlineBox], DisplayBox[OutlineBox]}

If you want a count of the number of the Outline Boxes, you would need to do something like

numOutlineBoxes = N Items( rpt << xpath( "//OutlineBox[contains(text(),'Standard Deviations')]" ));

Looking at the remainder of your JSL, it appears that you are confused with how to deal with the 20 different Standard Deviation Table Boxes.  You seem to want to take the count of the number of Standard Deviation Outline Boxes and somehow retrieve all of the data from all of the 20 Table Boxes all at once.  Your syntax is also incorrect, and returns an error message.  What I believe you want is:

sumFit = majorrptList[1][Number Col Box( 1 )] << Get as Matrix;

Which returns 

[3.67530167633204, 3.67530167633204, 7.01812976988444]

Which comes from the 1st Standard Deviation Outline Box in your journal

txnelson_0-1738077503661.png

You seem to want to use numOutlineBoxes in your reference, in an attempt to somehow get all of the data from all of the Table Boxes.  However, since the value of numOutlineBoxes is 20, what running

numOutlineBoxes = N Items( rpt << xpath( "//OutlineBox[contains(text(),'Standard Deviations')]" ));
sumFit = majorrptList[numOutlineBoxes][Number Col Box( 1 )] << Get as Matrix;

what you get is 

[0.00401248052954899, 0.00401248052954899, 0.0399901237806931]

which are the values from the 20th Standard Deviations Outline Box

txnelson_1-1738077940567.png

It appears that you are attempting to run before learning to walk.  I suggest you slow down and take the time to read though the Scripting Guide to gain a better understanding of JSL before you take on such a large project.

Jim