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
austinspencer
Level II

How to get the path to the current project file?

If I have a script within a project (or perhaps a reference to the project in a script outside of the project), how to do I get the file path to where the project is saved on disk?  I'm interested in doing this with JSL, not interactively.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to get the path to the current project file?

It turns out that message isn't available until (the future) JMP 18.2. 

 

In fact, I appears that I actually added it earlier this year in response to this question, but incorrectly marked it as having existing since JMP 14. Then I somehow forgot that I had done so, such that on reencountering this thread a few months later, I went looking for a solution and found the one I had recently created (but thought it was much older than it was). 

 

Sorry about that.

View solution in original post

12 REPLIES 12
austinspencer
Level II

Re: How to get the path to the current project file?

Based on the silence, I'm guessing that this may not be (easily) possible?

Craige_Hales
Super User

Re: How to get the path to the current project file?

I struggled with this too. Even if it was possible, it would not work for what I wanted to do because the files in a project are unpacked on demand, not when the project is first opened. My use case was needing a filepath for a resource in the project...that would go to an external program. I wound up using loadtextfile(proj file name)/savetextfile($temp/name) and sending the temp file name.

 

Using a Project for a Project - Audio.jsl passes a file to powershell to play.

 

What are you trying to do?

Craige
austinspencer
Level II

Re: How to get the path to the current project file?


What are you trying to do?


That's a good question, and probably one I should have answered in the original question.  When working on a project, sometimes it would be helpful to be able to quickly copy the path to the project to either open the containing folder to view other associated files or to store the link in my notes or send to a coworker.  This is a relatively common and useful feature found in many code editors and office suite software.  Of course you can just browse to the file through other means, but it's a common enough task for me that it's handy to have a quick method that doesn't require me to mentally parse my file organization structure each time.  Thanks for your time!

Craige_Hales
Super User

Re: How to get the path to the current project file?

@aaron_andersen , @julian  - He's right; I've resorted to using file->SaveAs to discover the path in the past. The home window's recent file list is better, offering both copy path and open containing window. Maybe those could also be exposed on data table, script, and project windows as well. The system popup off the title bar might be an alternative to the file menu.

I think projects may be a special case from JSL; data tables and scripts can already get their path.

 

Craige
austinspencer
Level II

Re: How to get the path to the current project file?


@Craige_Hales wrote:

@aaron_andersen, @julian  - He's right; I've resorted to using file->SaveAs to discover the path in the past.

Yeah, I've used that on occasion as well.  From what I recall, it won't work if you've not saved the project file since opening it though.

The home window's recent file list is better, offering both copy path and open containing window.

Ah, that's at least a decent workaround.  Thanks.

Maybe those could also be exposed on data table, script, and project windows as well. The system popup off the title bar might be an alternative to the file menu.

I think projects may be a special case from JSL; data tables and scripts can already get their path.

 


Having this function in some menu would be great.  If it were available through JSL as well, that would be a plus.

Re: How to get the path to the current project file?

I do not find a function specific to a JMP project. There is no path variable for projects either. You are free to save a project anywhere you like. It is a kind of JMP file, so when you open or save a project, JMP will start with the last directory. You can get this information using the Get Default Directory() function.

dir.JPG

austinspencer
Level II

Re: How to get the path to the current project file?

Thanks for looking into this.  I've had luck using Get Default Directory() in bare scripts, but when a script is saved in a project, it just returns the path inside the project file rather than where the project is stored:

Get Default Directory() = "jmpprj://contents/";

Re: How to get the path to the current project file?

Better late than never (I hope), I think what you're looking for is the Project File Path() message on the project itself.

 

From outside the project:

project = Open( "$SAMPLE_PROJECTS/Big Class.jmpprj" );

path = project << project file path();

Or inside the project using this project():

project = Open( "$SAMPLE_PROJECTS/Big Class.jmpprj" );

project << Run Script( 
    // this line should work from any JSL script executed from within the project
    path = this project() << project file path()
);
austinspencer
Level II

Re: How to get the path to the current project file?

Hi Aaron,

 

Always better late than never!  Is "project file path" new to JMP 18?  When I run the script in JMP 17, I get:

 

Object 'Project' does not recognize the message 'project file path'; perhaps you mean one of these:  <<Project Settings... <<Show Recent Files <<Reset Layout <<Get Layout <<Set Layout <<Run Script <<Set Report Title <<Dispatch <<Show Properties <<Get Script <<Get Display Path <<Get Project <<GetOffset <<Get Width <<Set Width <<Get Property List <<Get Properties <<Get Property List <<Get Properties <<Get Project.

Thanks,

Austin