Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar

Get pathname of current script

I would like a command to return the pathname of the JSL script.  For example, if I run a script "/Users/John_Doe/Documents/JMP/JMP Scripts/myscript.jsl", and I would like to have a command like this inside the script:


thispath = Get Current Script Path();   

And I would like this to return: "/Users/John_Doe/Documents/JMP/JMP Scripts/myscript.jsl"


The reason for this request:

I have a "common functions.jsl" script that many of my scripts call using "Include".  It contains many frequently used user functions that I don't want to copy into each new script I write.  I also like to share my scripts with others in my group, along with "common functions.jsl".  I can require that my group members place common functions.jsl in the same place relative to the JSL calling it (e.g. the same folder, or parent folder), but I can't control what the overall path names will be.  If I had the path name of the calling script, I could easily use that to figure out where "common function.jsl" is (e.g. "/Users/John_Doe/Documents/JMP/JMP Scripts/common function.jsl").


I cannot use Get Default Directory().  I've found this command returns only the path of the most recent file opened using the Open File dialog.  This works if the user opens the script and immediately runs it.  The problem is if the user opens another script after opening "myscript.jsl", but then tries to run "myscript.jsl".  It this case Get Default Directory() will return the path of the other script, not "myscript.jsl".  Also, Get Default Directory() does not get updated if a script is opened from the Recent Files list.  


Any suggestions, or is this something that doesn't exist yet?  Thanks for your help.

Tracking Number:

Defect ID: