cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
SDF1
Super User

How to create new data table script with variable directory paths

Hi All,

 

  I'm updating a script that I've been working on that after the analysis is done, I want to save a picture of the report window and then save a script to the data table that will open the image if the user wants to do that. Each analysis will generate a new report image, and I need the script saved to the data table reference that updated file name (all are in the same directory).

 

  Side note: I have to save the report as an image because I have some temporary data tables that are referenced in the creation of the report, and I don't want to save those data tables -- although saving them to the data table script would also be cool if someone has a solution for that.

 

  Anyway, what I'm having a hard time with is when the New Script is saved to the data table, it writes the variables in my main script, not the characters that I want. I have tried Eval Insert(), and Eval(Substitute(Expr())) as ways to try and get that, but nothing works.

 

Below is an example of one such output from the analysis:

SDF1_0-1692723771557.png

The analysis actually creates another data table in order to build the GB image on the lower right, this data table:

SDF1_1-1692723822865.png

But, when the analysis is over with, or the user performs an analysis on another column, this data table is deleted and I don't have a reference to it anymore -- I tried using the <<Save Script for All Objects to Data Table command, but this requires a reference to the above data table to then generate the graph builder, but the data table is now gone.

 

Instead, I'm having to save the window as a png, which is OK, and should look like the first image above, but as a PNG. One iteration of the code in the script where I'm doing this is here:

Button Box( "Save Results to DT",
	path = dt << Get Path; //gets the dt's path
	l = Length( path ) - Length( dt << GetName ) - 4; // takes off dt name and .jmp extension
	dir = Left( path, l ); //actual path where the PNG file is supposed to be saved
	If( N Items( Icols ) == 0 & N Items( Xcols ) == 0,
		pic_name = "Self_Corr_" || ycols[1] || ".png"; //name of the picture
		nwin[Outline Box( 1 )] << Save Picture( dir || pic_name, "png" ); //saves the report window as a PNG to the directory
full_name=dir||pic_name; dt << New Script( "Self Corr of " || ycols[1], Open( full_name ) ); // the new script is supposed to substitute the actual dir name and pic_name, not the variables. ); )

It creates a script to the data table that looks like this:

SDF1_3-1692724985070.png

But, the script should be this instead:

SDF1_4-1692725028809.png

Where I've copy/pasted what should be in the script to show what I'm trying to have the main script do. This should be doable, but all the attempts I've made don't work.

 

  As mentioned previously, I am OK with saving the reports as PNGs and the user just open the report as a PNG in JMP, but if possible, I'd rather have the temporary data tables saved to the New Script() so that when the user clicks on the script, it will generate the needed temporary data table for the full interactive ability, but I suspect that will be harder.

 

Thanks for any input or suggestions!,

DS

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to create new data table script with variable directory paths

You can store the table creation to as table script if you want, but these can get quite large and take a lot of space. You could also store the image to table. Below are three different options, remember to check how the scripts look within the table

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

// Saving table creation
dt_script = dt << Get Script;
Eval(EvalExpr(
	dt << New Script("Create Table", Expr(Name Expr(dt_script)));
));

// Saving image
img = Open("$SAMPLE_IMAGES/windmap.png", "png");
Eval(EvalExpr(
	dt << New Script("Open Image", 
		New Window("Image",
			Picture Box(Expr(img));
		)
	)
));

// Saving filepath which will open the image
file_path = "$SAMPLE_IMAGES/windmap.png";
Eval(EvalExpr(
	dt << New Script("Open File from Path", 
		Open(Expr(file_path))
	)
));

Btw, have you considered using JMP projects for this?

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: How to create new data table script with variable directory paths

You can store the table creation to as table script if you want, but these can get quite large and take a lot of space. You could also store the image to table. Below are three different options, remember to check how the scripts look within the table

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

// Saving table creation
dt_script = dt << Get Script;
Eval(EvalExpr(
	dt << New Script("Create Table", Expr(Name Expr(dt_script)));
));

// Saving image
img = Open("$SAMPLE_IMAGES/windmap.png", "png");
Eval(EvalExpr(
	dt << New Script("Open Image", 
		New Window("Image",
			Picture Box(Expr(img));
		)
	)
));

// Saving filepath which will open the image
file_path = "$SAMPLE_IMAGES/windmap.png";
Eval(EvalExpr(
	dt << New Script("Open File from Path", 
		Open(Expr(file_path))
	)
));

Btw, have you considered using JMP projects for this?

-Jarmo
txnelson
Super User

Re: How to create new data table script with variable directory paths

I second Jarmo's suggestion of looking at a JMP Project for the solution.

Jim
SDF1
Super User

Re: How to create new data table script with variable directory paths

Hi @jthi and @txnelson ,

 

  Thanks for the fast feedback and ideas. I appreciate the different options for saving the script to the data table. I ended up going with the image in the end because saving the temporary data table and then having to call that script with the New Script turned out to be complicated.

 

  I have considered Projects for this, but the way the users will interact with this, I don't think will be as helpful when in a Project format. I think I might be the only one in my organization that uses Projects. If that changes, I would definitely consider updating the code.

 

Thanks again for all the help!,

DS