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.
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.
Based on the silence, I'm guessing that this may not be (easily) possible?
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.
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?
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!
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/";
@aaron_andersen , @jules - 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.
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() );
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
Ah, I love the story. No worries. I can only laugh because it sounds exactly like the sort of thing I would do. The number of times I've written a function to solve a problem only to find I had made the exact same thing under a different name 6 months prior...
Anyway, I'm glad to hear the functionality is on the way!
Hi now we have JMP 18.2.where can it be queried?