Subscribe Bookmark RSS Feed

Finding a relative path in a network

anders_bankefor

Community Trekker

Joined:

Dec 8, 2015

I would like JMP to pick up a "template-table" from the same directory that the script is located. This pathway may vary depending on user due to network setup (for example for me the disk is named K but for other users it might be named L or N). I've managed to use the following "fixed" link:

TempTable = "K:\...\TableTemplate.jmp";

open (TempTable);

(this setup works)

the data table is located in the same directory as the script, therefore I would reason that I should be able to use:

TempTable ="..\[folder]\TableTemplate.jmp"

open (TempTable);

However this doesnt work.

Could anyone please give me suggestions on how to locate the folder where the script (not the table) is stored on the server.

Kind Regards

Anders

4 REPLIES
anders_bankefor

Community Trekker

Joined:

Dec 8, 2015

I would just like to add that I've tried to use:

path=get default directory()

without success

David_Burnham

Super User

Joined:

Jul 13, 2011

Are you saying that Get Default Directory does not return the location of the script file?

Usually paths are relative to the location of the script so if the table is in the same directory you can write

Open("test table.jmp")

Or if you have a folder containing scripts and another containing data tables (both at the same level) you can write

Open("../Data Tables Folder/test table.jmp")

Do you have a single script or are you using include files?

-Dave
txnelson

Super User

Joined:

Jun 22, 2012

What is the process for the user, to run this script?  Will they be opening up the script and then manually running the script by clicking on the "Run Script" icon, or will the script automatically run when opened?

I placed a simple script and a data table into the same directory, and then opened them from both under the JMP File==>Open and the Windows Explorer window, and have not had an issue when I use the following code:

//!

Names Default to Here(1);

path=get default directory();

dt=open(path||"couples golf members.jmp");

Jim
pmroz

Super User

Joined:

Jun 23, 2011

To avoid different disk drive mappings, you could use the long UNC-style name.  Something like:

\\disk.rd.com\folder1\folder2\folder3\TableTemplate.jmp

Alternatively I would recommend creating an addin.  Suppose your addin is called com.cmpny.dept.myapp.  The syntax would be:

TempTable = "$ADDIN_HOME(com.cmpny.dept.myapp)\TableTemplate.jmp";

open (TempTable);