<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic JSL Identify Path of the Currently Running Script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49539#M28169</link>
    <description>&lt;P&gt;When running a script (either from the script window or by triggering it from the add-in) I would like to be able to either (1) get at the location of the directory that the script window is in or (2) get the id of the add-in that contains the script. JMP knows this because it had to open the script to start executing this. Is there a way to do this?&lt;/P&gt;&lt;P&gt;I know I can do this in an add-in context by using $ADDIN_HOME(id). The issue here is I have a common include that I am packaging in multiple add-ins, and I'd rather not have to change the file for each different add-in. I can see myself accidentally making a copy of the common include from add-in #1 to add-in #2 and forgetting to change the id in the include so that it uses the right path in add-in #2.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2018 15:36:21 GMT</pubDate>
    <dc:creator>mjoner</dc:creator>
    <dc:date>2018-01-11T15:36:21Z</dc:date>
    <item>
      <title>JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49539#M28169</link>
      <description>&lt;P&gt;When running a script (either from the script window or by triggering it from the add-in) I would like to be able to either (1) get at the location of the directory that the script window is in or (2) get the id of the add-in that contains the script. JMP knows this because it had to open the script to start executing this. Is there a way to do this?&lt;/P&gt;&lt;P&gt;I know I can do this in an add-in context by using $ADDIN_HOME(id). The issue here is I have a common include that I am packaging in multiple add-ins, and I'd rather not have to change the file for each different add-in. I can see myself accidentally making a copy of the common include from add-in #1 to add-in #2 and forgetting to change the id in the include so that it uses the right path in add-in #2.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 15:36:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49539#M28169</guid>
      <dc:creator>mjoner</dc:creator>
      <dc:date>2018-01-11T15:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49541#M28170</link>
      <description>&lt;P&gt;Why not make the common include file it's own addin.&amp;nbsp; That way you can include it via something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Load functions common to various apps
include("$ADDIN_HOME(com.cmpny.dept.common)\General Functions.jsl");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jan 2018 15:44:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49541#M28170</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-01-11T15:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49543#M28172</link>
      <description>&lt;P&gt;Yes, but I want to include a line in General Functions.jsl that identifies which other add-in is calling a function in General Functions.jsl.&lt;/P&gt;&lt;P&gt;In other words, in com.cmpny.dept.addin1 a script might call a function in General Functions.jsl. I want to refer to a variable in General Functions.jsl that will reveal that&amp;nbsp;com.cmpny.dept.addin1 called it.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 15:51:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49543#M28172</guid>
      <dc:creator>mjoner</dc:creator>
      <dc:date>2018-01-11T15:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49545#M28173</link>
      <description>&lt;P&gt;If I can't get that com.cmpny.dept.addin1 called it, and I DON'T use the common add-in approach pmroz is suggesting, then knowing what folder that script was in is good enough because I can open the addin.def from the same folder and extract the id from there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This actually gives me a second potential application. If I can get in the addin.def of a currently-running add-in (but right now I can't seem to do this), I could do a version check by getting the id and addinVersion from addin.def and then compare that to a list of latest add-in versions that I might get using Internet Open. I could then find out whether the user's local addinVersion is the latest and greatest.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 16:00:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49545#M28173</guid>
      <dc:creator>mjoner</dc:creator>
      <dc:date>2018-01-11T16:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49549#M28176</link>
      <description>&lt;P&gt;I typically use either the Get Default Directory function or the Convert File Path function with an empty string to get the path of the current script.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;path1 = Get Default Directory();
path2 = Convert File Path( "" );

Show( path1, path2 );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's the log when I run this script from a file located within my "C:\Public" folder:&lt;/P&gt;
&lt;PRE&gt;path1 = "/C:/Public/";
path2 = "/C:/Public/";&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jan 2018 16:22:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49549#M28176</guid>
      <dc:creator>Justin_Chilton</dc:creator>
      <dc:date>2018-01-11T16:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49577#M28198</link>
      <description>&lt;P&gt;Get Default Directory combined with locating the DEF file sounds like it would work but seems like an uncomfortable hack.&amp;nbsp; The payback is probably worth it - I have a standard include file for all my filepath definitions but with separate revisions for each addin (i.e. the same problem you describe) so being able to dynamically discover the ID of the parent addin would be an extremely useful feature.&amp;nbsp; So much so, the hack is starting to sound attractive - hadn't thought about reading the DEF file ...&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 22:39:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/49577#M28198</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2018-01-11T22:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/236236#M46614</link>
      <description>&lt;P&gt;The solution is not working for me, the resulting path is with forward slashes /, I need it with backward slash \. Does someone know a solution?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 08:41:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/236236#M46614</guid>
      <dc:creator>PhiIippe</dc:creator>
      <dc:date>2019-11-25T08:41:39Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/236266#M46624</link>
      <description>&lt;P&gt;JMP and JSL don't care about the orientation of the slashes. They will work either way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to use the path string outside of JMP you can use &lt;A href="https://www.jmp.com/support/help/14-2/substitute-and-substitute-into.shtml" target="_self"&gt;Substitute Into():&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;foo="c:/my directory/my directory/my directory";

substitute into(foo, "/", "\");

show(foo);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Nov 2019 14:09:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/236266#M46624</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2019-11-25T14:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/236276#M46626</link>
      <description>&lt;P&gt;I like Jeff's solution. But there is a dedicated utility function, too, for this purpose. Here is an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Convert File Path( "$HOME", Windows );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It can do more than change the format from POSIX to Windows. See Help &amp;gt; Scripting Index &amp;gt; Functions &amp;gt; POSIX.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 14:27:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/236276#M46626</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2019-11-25T14:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/237099#M46812</link>
      <description>&lt;P&gt;Thanks Jeff, this is great!&lt;BR /&gt;&lt;BR /&gt;I did find another solution though: I saved my script in the same directory as the current data table, then I get the path of my datatable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
path = dt&amp;lt;&amp;lt; getpath;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;The resulting "path" is my directory path with backward slashes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2019 19:47:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/237099#M46812</guid>
      <dc:creator>PhiIippe</dc:creator>
      <dc:date>2019-12-03T19:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Identify Path of the Currently Running Script</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/366774#M61655</link>
      <description>&lt;P&gt;There is also a built-in function to translate between the POSIX and Windows path delimiter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="convert.PNG" style="width: 804px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/31146i849BD3AA734E8C49/image-size/large?v=v2&amp;amp;px=999" role="button" title="convert.PNG" alt="convert.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 11:54:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Identify-Path-of-the-Currently-Running-Script/m-p/366774#M61655</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2021-03-10T11:54:41Z</dc:date>
    </item>
  </channel>
</rss>

