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

How to Implement "Saving Your Work in a JMP Journal" using JSL

Based on the information shared below, it is possible to create links to a JMP Journal by using the "open all files" method.

https://community.jmp.com/t5/Statistical-Thinking-for/Saving-Your-Work-in-a-JMP-Journal/ta-p/271841

 

I would like to implement a feature in the GUI where a button can be clicked to create a journal link similar to the method shown in the referenced video (without transferring the entire GUI interface to the Journal, but only creating a link). The JSL for creating a journal link only allows connecting data tables. How can I create a link for all the charts in the new window? I appreciate any assistance in this matter.
For example, how can I transfer the following new window to a JMP Journal and present it in the form of a link?

//
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
nw2= New Window( "New window",
Bivariate( y( :weight ), x( :height ) );
);
nw2 << Save ByGroup Script to Journal;

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to Implement "Saving Your Work in a JMP Journal" using JSL

I am not exactly sure what you want, But might this be it

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
nw2 = New Window( "New window",
	biv = Bivariate( y( :weight ), x( :height ) )
);
biv << Save ByGroup Script to Journal;
Current Journal() << append( ob = Outline Box( "All Files" ) );
ob << Add All Open Files;

P.S.  Please use the JSL icon at the top of the Preview window when entering JSL.  It makes for easier reading and understanding of your code.

Jim

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: How to Implement "Saving Your Work in a JMP Journal" using JSL

I am not exactly sure what you want, But might this be it

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
nw2 = New Window( "New window",
	biv = Bivariate( y( :weight ), x( :height ) )
);
biv << Save ByGroup Script to Journal;
Current Journal() << append( ob = Outline Box( "All Files" ) );
ob << Add All Open Files;

P.S.  Please use the JSL icon at the top of the Preview window when entering JSL.  It makes for easier reading and understanding of your code.

Jim
BabyDoragon
Level I

Re: How to Implement "Saving Your Work in a JMP Journal" using JSL

 
This is exactly the result I wanted.
Additionally, besides the method of "add all open files", is there a way to only add a specific "specified name" open file? For example, only add the link of  "New window" into Journal list.
txnelson
Super User

Re: How to Implement "Saving Your Work in a JMP Journal" using JSL

I should have pointed you to the Scripting Index(under Help pull down) in my first response to your question.  The Scripting Index will show you the messages that can be passed to objects, such as the Add All Open Files message.  In my first response you will note that the message is being sent to an OutlineBox() referenced by the variable "ob".  If you look in the Scripting Guide and select OutlineBox, you will see all of the messages that you can specify to add items to it.

txnelson_0-1724763660084.png

 

Jim
BabyDoragon
Level I

Re: How to Implement "Saving Your Work in a JMP Journal" using JSL

I think I didn't explain the problem clearly. What I want to ask is if "add all open files" automatically sends all currently open JMP files as linked objects. However, what I want is for the user to be able to select only the desired files from these open windows, rather than adding all of them, and not using the "Add File Reference" to add saved files. As shown in the following image, I want the user to be able to select the "open file" they want to add.

BabyDoragon_0-1724819807846.png

 

txnelson
Super User

Re: How to Implement "Saving Your Work in a JMP Journal" using JSL

My previous response was apparently not very clear.  My pointing yo9 to the Scripting index and the various messages that can be passed to an Outline Box is intended to point you to a good source for figuring out how to write the JSL to solve the specific requirements you have.

Jim
BabyDoragon
Level I

Re: How to Implement "Saving Your Work in a JMP Journal" using JSL

Thank you for your response. I understand what you mean. You are saying that I need to send the items I want to save to the outline box for recording. However, I currently only know that "ob << add all open files" can be used to send all open files at once. I don't know how to send a specific open file to the outline box. Can you give me some hints?
Also, I have additional question. When I use "ob << add all open files" and the link appears on the Journal, I noticed that the functionality of buttons seems to disappear. For example, in the JSL shown below, there was initially a button, but it seems to be missing after clicking the link in the Journal. How can I make that the functionality of the button continues to exist?

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
nw2 = New Window( "New window",
outputGButton = Button Box( "Test", print("test");
				),
	biv = Bivariate( y( :weight ), x( :height ) )
);
nw2 << Save ByGroup Script to Journal;
Current Journal() << append( ob = Outline Box( "All Files" ) );
ob << Add All Open Files;
txnelson
Super User

Re: How to Implement "Saving Your Work in a JMP Journal" using JSL

The JSL from your latest response creates a Window Object display box with a variable named "nw2" that is used to allow one to reference that display box.  The default action of a Window Object is to create a new display window

nw2 = New Window( "New window",

Inside the Window Object a Button Box Display Box with the name, "Test" and a script, "Print("test")". with a variable named "OutputGButton" that is used to reference the Button Box.

outputGButton = Button Box( "Test", print("test");
				)

The next object within the Window Object is the JSL to run a Bivariate Platform, with a variable named "biv" that is used to reference the Bivariate Platform object.  The default action of the Bivariate Platform is to run a Bivariate analyses and to display the output in either a new window or in this instance to display the output within the nw2 window object.  2 elements are passed to the Bivariate Platform. The column weight is passed to the Y element, and the column height is passed to the X element

biv = Bivariate( y( :weight ), x( :height ) )

At this point in the JSL, the definition of the nw2 window object is completed the a closing ")"

I am going into this level of detail in order to illustrate how the next lines within the script interact with the nw2 window object or with one of the objects within the nw2 window object.

Each of the defined object have messages that can be passed to them.  Different types of objects have a different list of messages that can be passed to them.  The nw2 window object has messages such as "Set Window Title", "Bring Window To Front", "Close Window" etc.  The complete list of messages that can be sent to a window object are listed in the Scripting Index

txnelson_0-1724851370487.png

in the current script

nw2 << Save ByGroup Script to Journal;

it has the "Save ByGroup Script to Journal" message being passed to the nw2 window object.  However, that message is not a message available to a window object.  

Save ByGroup Script to Journal is a message that is available to JMP Platforms.

The only object in the script that this message can be passed to is the Bivariate platform referenced by the biv variable

biv << Save ByGroup Script to Journal;

However, when this is the way it is used, the script that is passed to the journal only contains the JSL to run the Bivariate, not the script to run the full JSL that creates the window object with it's button box and Bivariate platform.

 

So what will need to be done, is to write the JSL that places into a journal a button box that contains all of the JSL that is currently in the definition of the nw2 window object.

 

Basically what the Save ByGroup Script to Journal does, is to create a button box with a specified script.  If the requirement is to have something different in the button box that what the given functionality is, then it is up to the user to write the code to make the changes.  Below is a script that does the same thing as the Save ByGrooup.... but adds in the specified button box before the output of the Bivariate

Names Default To Here( 1 );
//dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
file = pick file();
dt = open(file);
biv = dt << Bivariate( y( :weight ), x( :height ), invisible );
theScript = Char( biv << get script );
biv << close window;
Eval(
	Parse(
		"New Window( \!"My Journal\!",
	<<journal, 
	bb = Button Box( \!"Dummy\!",
		nw2 = New Window( \!"Output\!",
			outputGButton = Button Box( \!"Test\!", Print( \!"test\!" ) ),
			open(\!"" || file || "\!") << 
			" || theScript || ";
		)
	)
);
bb << style( \!"Underline\!" );
bb << set button name( dt << get name || Word( 1, theScript, \!"(\!" ) );
Current Journal() << append( ob = Outline Box( \!"All Files\!" ) );
ob << Add All Open Files(menu(1));
"
	)
);

It also uses the Menu(1) addition to the Add All Open Files, to let the user choose the files to add

Jim
mmarchandFSLR
Level IV

Re: How to Implement "Saving Your Work in a JMP Journal" using JSL

It's less obvious here than in many cases, but, as Jim was alluding to, the Scripting Index does give the solution.  << Add All Open Files has an optional argument that will allow you to choose the files you want to link to in the Outline Box.

mmarchandFSLR_0-1724857017516.png

ob << Add All Open Files( Menu( 1 ) );

mmarchandFSLR_1-1724857414425.png