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
ariel
Level I

Save charts as ".jrp" file in JSL

Hi guys

During my work I came across a requirement to save charts as report in JMP (".jrp" file) - a chart which created during a script run.

After long day of trying all code combination for saving files in JSL it looks like there is no commend for saving in a "report" type -

only journal (".jrn"), .pdf and others...

Also, while searching in the forums I found that the last time someone asked similar question in the subject it was in 2011 and no one had an answer..

so:

Can I save ".jrp" file in jsl ?

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Save charts as ".jrp" file in JSL

This question comes up fairly often.  Unfortunately, there is not a JSL command to save a report directly as a JRP file.  This has been suggested previously as a feature for consideration in a future release of JMP. 

 

As noted previously, a JRP file is simply a text file containing JSL code.  You can extract the script from the platform and then use Save Text File to save the file path and script into a text file with the JRP file extension.  Here is a more simple example that may help to clarify:

 

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dist = dt << Distribution(
  Continuous Distribution( Column( :weight ) ),
  Nominal Distribution( Column( :age ) )
);
distScript = dist << Get Script;
Save Text File(
  "C:\temp\DistributionScript.jrp",
  "//!
    Open( \!"$SAMPLE_DATA\Big Class.jmp\!" );"
    ||
  Char( Name Expr( distScript ) )
);
Close( dt, No Save );
Wait( 2 ); //For demonstration purposes
Open( "C:\temp\DistributionScript.jrp" );

 

 

Hope that helps!

Wendy

View solution in original post

Jeff_Perkinson
Community Manager Community Manager

Re: Save charts as ".jrp" file in JSL

In JMP 16 the <<Save Window Report message will save a report as a .JRP file.

 

Names Default To Here( 1 );
//This message can be sent to any display box object but will be applied to the report window
Open( "$SAMPLE_DATA/Big Class.jmp" );
d = distribution( Column( :height ) );
d << Save Window Report(
	"$DOCUMENTS/test.jrp",
	embed data( 1 )
);

 

 

-Jeff

View solution in original post

7 REPLIES 7
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Save charts as ".jrp" file in JSL

Save as .jrp with some interactivity:

 

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( Y( :Weight ), X( :Height ) );
Wait(1);
biv<< Bring Window To Front;
Main Menu( "Save As" );

 

Save as .jrp automatically:

A .jrp appears to be just a .jsl that autoruns. The code contains 1) a reference to a saved data table or to an embedded data table, and 2) the code to generate the report. Hence, it should be quite straightforward to script the saving of a .jrp.

Here is one way that seems to work:

 

 

// Function to save .jrp
Save_jrp = Function( {dt, obj, dir, filename},
    {embed_data = 0}, // Switch between embedded and referenced data table.
    Save Text File(
        dir || filename || ".jrp",
        If( embed_data,
            Char(
                Eval Expr(
                    Expr( dt << get script );
                    Expr( obj << get script );
                )
            ),
            Char(
                Eval Expr(
                    Open( Expr( dt << get path ) );
                    Expr( obj << get script );
                )
            )
        )
    )
);
 
// Define example input data: data table, report, path and file name
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( Y( :Weight ), X( :Height ) );
dt = biv << get data table;
biv << set window title( "MyReport" );
fname = biv << get window title;
path = Get Default Directory();
 
// Run function
Save_jrp( dt, biv, path, fname );
 
// Test if it worked
Close( dt, no save );
Wait( 1 );
Open( path || fname || ".jrp" );

 

ariel
Level I

Re: Save charts as ".jrp" file in JSL

Hi, thanks for your answer and for your code

I really appreciate u took the time and built this function all for me,

The problem is it doesn't really work under my conditions... What u wrote is indeed working, but not for my needs.

For some reason it just save the table again and no the report

msharp
Super User (Alumni)

Re: Save charts as ".jrp" file in JSL

I think you just took the code without any thought to the principle behind it.

From testing out the function it does indeed save the report, but there are often errors due to undefined variables if your report is anything complex.  But let's read the principle behind why the function works.


What MS wrote:

Save as .jrp automatically:

A .jrp appears to be just a .jsl that autoruns. The code contains 1) a reference to a saved data table or to an embedded data table, and 2) the code to generate the report. Hence, it should be quite straightforward to script the saving of a .jrp.

(underlined for emphasis)

Thus, if you have a script that generates a report, just save the script as a .jrp instead of a .jsl.

vishwasanj
Level V

Re: Save charts as ".jrp" file in JSL

This is a nice code. Thank you MS. If I have multiple graphs in one page with oneway distribution, tables and graph builder using H list Box and V list box, for some reason obj<< get script shows an error. Do I have to use a parent directory?

Re: Save charts as ".jrp" file in JSL

This question comes up fairly often.  Unfortunately, there is not a JSL command to save a report directly as a JRP file.  This has been suggested previously as a feature for consideration in a future release of JMP. 

 

As noted previously, a JRP file is simply a text file containing JSL code.  You can extract the script from the platform and then use Save Text File to save the file path and script into a text file with the JRP file extension.  Here is a more simple example that may help to clarify:

 

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
dist = dt << Distribution(
  Continuous Distribution( Column( :weight ) ),
  Nominal Distribution( Column( :age ) )
);
distScript = dist << Get Script;
Save Text File(
  "C:\temp\DistributionScript.jrp",
  "//!
    Open( \!"$SAMPLE_DATA\Big Class.jmp\!" );"
    ||
  Char( Name Expr( distScript ) )
);
Close( dt, No Save );
Wait( 2 ); //For demonstration purposes
Open( "C:\temp\DistributionScript.jrp" );

 

 

Hope that helps!

Wendy
sankuan
Level I

Re: Save charts as ".jrp" file in JSL

Hi Wendy,

 

Good day! I am new in scripting, and still learning.

I read your code and try to execute it. I realized that if i don't include "by(:pin_group)".. it will save a JMP report

This is the line that i used for testing.

 

dist= dt << Distribution( Continuous Distribution( Column( :Measurement ),Normal Quantile Plot( 0 ) ), by(:pin_group));

 

What i am trying to do is:

1. Get the distribution (by group ~ 23 groups)

2. Perrform modification on the histogram (Both axis and add ref line - for all the histogram generated)

3. Save as JRP (Your example - code), histogram with the data table. >> This is where i am facing problem. 

 

Is there a specific code to save as JRP with multiple histograms in the same report?

 

Please educate me. Thanks and appreciate your help!

Jeff_Perkinson
Community Manager Community Manager

Re: Save charts as ".jrp" file in JSL

In JMP 16 the <<Save Window Report message will save a report as a .JRP file.

 

Names Default To Here( 1 );
//This message can be sent to any display box object but will be applied to the report window
Open( "$SAMPLE_DATA/Big Class.jmp" );
d = distribution( Column( :height ) );
d << Save Window Report(
	"$DOCUMENTS/test.jrp",
	embed data( 1 )
);

 

 

-Jeff