cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
RobertB
Level II

Usability of Projects via JSL

Hi all,
I have several jsl scripts dealing with data fetching from databases, "manipulation" and analysis of these with regards to different tasks.
For organization purpose I like to use "Projects" as all data tables and graphs and journals etc. can be stored in "one" file.
However, I struggle with the automation of the save procedure of the respective contents.
All files are stored under "Workspace". This is not actually stored in the project (which would need the files to be stored under "Contents").
I could not find a way that my script automatically stores the files under "Contents" or in later step be moved there.

My basic JSL code (using JMP16) looks like:

1. Version

project = New Project();
project << Set Window Title( " blahblah " );
Move to Project( destination( project ), windows( {dt1, dt2, dt3} ) );

2. Version

prj = New Project(
	run script(
...
)
);

Actually, both will end up with the same result all files (data tables and graphs) are under Workspace and I need to save them manually under Contents within this Project.

Any support / tips for data handling in Projects would be greatly appreciated!
I discussed the matter also with Martin and he proposed to use your knowledge / experience!

Thanks!

Cheers

Robert

@martindemel 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Usability of Projects via JSL

The easiest way to save things to the project contents in JSL is via the $PROJECT special directory, which can be used (similar to $SAMPLE_DATA, $DESKTOP, etc) in just about every JSL API that uses paths.

 

$PROJECT is only defined inside of projects, so when creating a project via JSL it has to be inside of the Run Script() command:

prj = New Project(
	Run Script(
		dt = new Table("My table");
		dt << Save As("$PROJECT/my table.jmp");
	)
);

or like this:

dt = Open("$SAMPLE_DATA/Big Class.jmp");
w = dt << Run Script("Bivariate");

prj = New Project();

Move to Project( destination( prj ), windows( {dt, w} ) );

prj << Run Script(
	Create Directory("$PROJECT/my folder");
	Data Table("Big Class") << Save As("$PROJECT/my folder/Big Class.jmp");
);

or even:

prj = New Project();

prj << Run Script(
	Copy File("$SAMPLE_DATA/Big Class.jmp", "$PROJECT/data/Big Class.jmp");
);

 

Hope that helps!

Aa

View solution in original post

4 REPLIES 4

Re: Usability of Projects via JSL

The easiest way to save things to the project contents in JSL is via the $PROJECT special directory, which can be used (similar to $SAMPLE_DATA, $DESKTOP, etc) in just about every JSL API that uses paths.

 

$PROJECT is only defined inside of projects, so when creating a project via JSL it has to be inside of the Run Script() command:

prj = New Project(
	Run Script(
		dt = new Table("My table");
		dt << Save As("$PROJECT/my table.jmp");
	)
);

or like this:

dt = Open("$SAMPLE_DATA/Big Class.jmp");
w = dt << Run Script("Bivariate");

prj = New Project();

Move to Project( destination( prj ), windows( {dt, w} ) );

prj << Run Script(
	Create Directory("$PROJECT/my folder");
	Data Table("Big Class") << Save As("$PROJECT/my folder/Big Class.jmp");
);

or even:

prj = New Project();

prj << Run Script(
	Copy File("$SAMPLE_DATA/Big Class.jmp", "$PROJECT/data/Big Class.jmp");
);

 

Hope that helps!

Aa

RobertB
Level II

Re: Usability of Projects via JSL

Hi Aaron,

that helps a lot for data tables!

Thanks!

However, I also have a Journal which I would like to save under Contents (manually no problem but I want JSL to do it for me ...).

It seems not to work for Journals?
Is your suggested approach only working for data tables? (probably I am missing something...)

Thanks!

Robert

// Initialization
Names Default To Here( 1 );

dt = Open("$SAMPLE_DATA/Big Class.jmp");
w = dt << Run Script("Bivariate");
obj = w << Journal;
jrn = Current Journal();
jrn << Set Window Title( "Journal" );

prj = New Project();

Move to Project( destination( prj ), windows( {dt, w, jrn} ) );

prj << Run Script(
	Create Directory("$PROJECT/my folder");
	Data Table("Big Class") << Save As("$PROJECT/my folder/Big Class.jmp");
	Current Journal() << Save As("$PROJECT/my folder/Journal.jrn");	
);

 

RobertB
Level II

Re: Usability of Projects via JSL

Found it myself ...
Journals need to be saved like:

obj << SaveJournal("PATH");

Thanks!
Robert

Re: Usability of Projects via JSL

Glad you got it working!

 

As for Journals not accepting << Save As(), that's the kind of thing I'd consider a bug in JSL. Any time the really obvious syntax doesn't work, even if some other less obvious one does, let JMP tech support know about it. They'll file a bug with your comments and forward it on to the appropriate JMP developer. While I can't make specific promises, we prioritize customer-reported issues highly, so there's a good chance we can get it fixed by the next release.

 

Aa