<?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 Re: Scripting: Getting the (absolute) path of the script itself in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/39839#M23323</link>
    <description>&lt;P&gt;Not sure how long this function has been around, as I am fairly new to JMP, and I just found this function myself while trying to solve a similar problem, but it seems that the function "Include File List()" returns a list of open files that are in the context of the executing script. &amp;nbsp;(By the way, the description of this function is only sort of informative, as is the case for most functions/methods/messages in the Scripting Index or online resources.) &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems that if this function is run at the top of the script before anything else is opened by the script that the script file path and script file name can be extracted from that as this is the only path returned at that point. &amp;nbsp;&lt;/P&gt;&lt;P&gt;When I tested it with other files open in JMP, and ran the script by double clicking it from Windows Explorer (with the script set to run on open without opening a script editor window by including "//!" at the top of the script), I get only the path of that script returned. &amp;nbsp;None of the other opened files are returned. &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jun 2017 14:40:38 GMT</pubDate>
    <dc:creator>BioData41</dc:creator>
    <dc:date>2017-06-01T14:40:38Z</dc:date>
    <item>
      <title>Scripting: Getting the (absolute) path of the script itself</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5296#M5295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi JMP-Users,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'm writing a script that uses several files that should be located in the same directory, like the script file. At the moment i am accessing these files using the "get current directory" command. Sadly this does only work if the user opened an instance of JMP by double-clicking on the script in his explorer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If JMP is already running and the user opens the script via File -&amp;gt; Open -&amp;gt; ... . The current directory is the path of the JMP installation not the path of the scriptfile.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to get the path of the scriptfile, to solve this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sebastian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jul 2012 13:15:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5296#M5295</guid>
      <dc:creator>statcon</dc:creator>
      <dc:date>2012-07-20T13:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Getting the (absolute) path of the script itself</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5297#M5296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This might do what you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;get default directory()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I usually strip off the first character because it's a forward slash, something like "/M:/myapplication/bigdata/"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;app_path = Substr(Get Default Directory(), 2, 999);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 13:09:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5297#M5296</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2012-07-23T13:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Getting the (absolute) path of the script itself</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5298#M5297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thats it!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks You!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jul 2012 13:50:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5298#M5297</guid>
      <dc:creator>statcon</dc:creator>
      <dc:date>2012-07-23T13:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Getting the (absolute) path of the script itself</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5299#M5298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Get Default Directory () works great....except when users map a network drive (e.g. X:\mynetworkpath\test.jsl).&amp;nbsp; Then you get the truncated path and not the full path (e.g. \\yournetwork.jmp.com\blahblah\mynetworkpath\test.jsl).&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone knows a way around this, that is a way to actually read in the full path even if mapped, let me know!&amp;nbsp; thx.. dj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 19:31:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5299#M5298</guid>
      <dc:creator>djhanson</dc:creator>
      <dc:date>2012-08-29T19:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Getting the (absolute) path of the script itself</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5300#M5299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In regular SAS I have just parsed the output of the Windows (DOS) command "net use" to find the volume that is mapped to a particular drive letter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 19:42:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5300#M5299</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-29T19:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Getting the (absolute) path of the script itself</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5301#M5300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom.&amp;nbsp; That's a great idea!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I only wish that "net use" was a Windows Environmental Variable then I would simply use something like: Get Environment Variable("NETUSE") (which doesn't work of course).&amp;nbsp; dj&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2012 19:56:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/5301#M5300</guid>
      <dc:creator>djhanson</dc:creator>
      <dc:date>2012-08-29T19:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Getting the (absolute) path of the script itself</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/35656#M21027</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4550"&gt;@pmroz&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;This might do what you want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;get default directory()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I usually strip off the first character because it's a forward slash, something like "/M:/myapplication/bigdata/"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;app_path = Substr(Get Default Directory(), 2, 999);&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;This solution fails in the following case: if your script or application is launched via hyperlink from an HTML document, Get Default Directory() may return a temporary folder created by the web browser.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 13:46:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/35656#M21027</guid>
      <dc:creator>andrew_iyengar</dc:creator>
      <dc:date>2017-02-10T13:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Getting the (absolute) path of the script itself</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/35659#M21030</link>
      <description>&lt;P&gt;With a poorly thought out regex...maybe it is good enough...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;txt = runprogram(executable("net"), options({"use"}), readfunction("text"));
show(regex(txt,"U:[ \t]*([^ \t]*)","\1")); // find the "U:" drive&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the txt value looks like this, before the regex&lt;/P&gt;
&lt;PRE&gt;"New connections will be remembered.
Status       Local     Remote                    Network
-------------------------------------------------------------------------------
             U:        \\network\root\u\chales   Microsoft Windows Network
The command completed successfully.
"&lt;/PRE&gt;
&lt;P&gt;the regex captures this&lt;/P&gt;
&lt;PRE&gt;Regex(txt, "U:[ \t]*([^ \t]*)", "\1") = "\\network\root\u\chales";
&lt;/PRE&gt;
&lt;P&gt;The 2nd argument to the regex is the pattern, which means&lt;/P&gt;
&lt;P&gt;find U:, followed by zero or more blanks or tabs, then zero or more characters that are not blanks or tabs. That last bit is in parens, which form capture group \1, which is also the third argument that specifies what the result of the regex will be.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2017 16:24:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/35659#M21030</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2017-02-10T16:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Getting the (absolute) path of the script itself</title>
      <link>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/39839#M23323</link>
      <description>&lt;P&gt;Not sure how long this function has been around, as I am fairly new to JMP, and I just found this function myself while trying to solve a similar problem, but it seems that the function "Include File List()" returns a list of open files that are in the context of the executing script. &amp;nbsp;(By the way, the description of this function is only sort of informative, as is the case for most functions/methods/messages in the Scripting Index or online resources.) &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems that if this function is run at the top of the script before anything else is opened by the script that the script file path and script file name can be extracted from that as this is the only path returned at that point. &amp;nbsp;&lt;/P&gt;&lt;P&gt;When I tested it with other files open in JMP, and ran the script by double clicking it from Windows Explorer (with the script set to run on open without opening a script editor window by including "//!" at the top of the script), I get only the path of that script returned. &amp;nbsp;None of the other opened files are returned. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2017 14:40:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Scripting-Getting-the-absolute-path-of-the-script-itself/m-p/39839#M23323</guid>
      <dc:creator>BioData41</dc:creator>
      <dc:date>2017-06-01T14:40:38Z</dc:date>
    </item>
  </channel>
</rss>

