cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
ariel
Level I

get current dir path from other file (not the jsl file)

Hi guys:)

Small but important question,

I wish to extract the directory path of a table  that's used in my script...

To be clear : when I use the function "get default directory()"  inside the code - it returns the path from were the script file is and not were the data table I use inside the script - (at the beginning the script working on a table that's "currently open" and in the view of current data table).

So, the question is:

How do i get the path of the data table and no the path of the script file

Thanks, Ariel

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: get current dir path from other file (not the jsl file)

dt = Current Data Table();

dt << getpath;

"C:\Users\...\Desktop\results 2.jmp"

Craige

View solution in original post

7 REPLIES 7
Craige_Hales
Super User

Re: get current dir path from other file (not the jsl file)

dt = Current Data Table();

dt << getpath;

"C:\Users\...\Desktop\results 2.jmp"

Craige
ariel
Level I

Re: get current dir path from other file (not the jsl file)

Thanks!!, it worked

Craige_Hales
Super User

Re: get current dir path from other file (not the jsl file)

Welcome.  I found the data table message like this:

dt = open("$SAMPLE_DATA/big class.jmp");

showProperties( dt );

Begin Data Update [Action] [Scripting Only]

Clear Column Selection [Action] [Scripting Only]

Recode [Action] [Scripting Only]

...

Copy Multi Columns Properties [Action] [Scripting Only]

Paste Multi Columns Properties [Action] [Scripting Only]

Get Labeled Rows [Action] [Scripting Only]

Get Name [Action] [Scripting Only]

Get Path [Action] [Scripting Only]

Get Property [Action] [Scripting Only]

Get Row States [Action] [Scripting Only]

Get Rows Where [Action] [Scripting Only]

...

The data table is a scriptable object in JMP.  The Show Properties function works with any scriptable object.  The list is the set of messages the data table responds to.  There is more information, and a similar list, in the Help->Scripting Index.

7926_ScriptingIndex.PNG

If you know a keyword, like "path", you can narrow the search:

7932_ScriptingIndexNarrow.PNG

The scripting index can search just Objects, just Functions, just Display boxes, or all three.  In this case, picking Objects, then Data Table, makes it easier because there are a number of Functions and Display boxes that know something about a path as well.

Craige
UersK
Level III

Re: get current dir path from other file (not the jsl file)

Thanks!

Rock123
Level I

Re: get current dir path from other file (not the jsl file)

I have similar question. the function "get default directory()"  inside the code is to return scrip file's direction path. how can I get the data table direction path that's "currently open". your previous reply about "getpath" is to show direction path + file name but my intention is to get direction path without file name, same output template as "get default directory". how can do it? looking forward to your reply. thank you. 

jthi
Super User

Re: get current dir path from other file (not the jsl file)

After you get the full path there are many different ways how you can drop the filename. Below is one option

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
cur_path = dt << Get Path;
path_as_list = Words(cur_path, "\/");
path_without_filename = Concat Items(Remove(path_as_list, -1), "/");
Show(cur_path);
//cur_path = "C:\Program Files\SAS\JMPPRO\16\Samples\Data\Big Class.jmp";
Show(path_without_filename);
//path_without_filename = "C:/Program Files/SAS/JMPPRO/16/Samples/Data";

There might be a function which lets you do this easier. If there is one you should be able to find it from File section of Scripting Index

jthi_0-1673081468469.png

Or from here JSL Syntax Reference > JSL Functions, Operators, and Messages > File Functions , convert file path would be my starting point

 

-Jarmo
Rock123
Level I

Re: get current dir path from other file (not the jsl file)

it's really helpful. thank you!