Subscribe Bookmark RSS Feed

Save charts as ".jrp" file in JSL

ariel

Community Trekker

Joined:

Jan 14, 2015

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
Wendy_Murphrey

Joined:

Jun 23, 2011

Solution

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
5 REPLIES
ms

Super User

Joined:

Jun 23, 2011

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

Community Trekker

Joined:

Jan 14, 2015

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

Joined:

Jul 28, 2015

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

Frequent Contributor

Joined:

Dec 27, 2016

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?
Wendy_Murphrey

Joined:

Jun 23, 2011

Solution

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