<?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: Custom Functions from within Projects in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/808125#M98757</link>
    <description>&lt;P&gt;Previous discussion with a similar topic:&lt;/P&gt;&lt;P&gt;&lt;LI-MESSAGE title="Unable to run addins within Project" uid="383815" url="https://community.jmp.com/t5/Discussions/Unable-to-run-addins-within-Project/m-p/383815#U383815" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Oct 2024 05:16:11 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2024-10-25T05:16:11Z</dc:date>
    <item>
      <title>Namespaces and Projects</title>
      <link>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/807137#M98596</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;we use some Custom Functions which we share with other colleagues via an AddIn.&lt;/P&gt;&lt;P&gt;The "custom" namespace is created in the global namespace, functions can be accessed via &lt;FONT face="courier new,courier"&gt;custom:myfunction&lt;/FONT&gt;.&lt;BR /&gt;&lt;BR /&gt;The issue: Some colleagues use Projects.&lt;BR /&gt;a project has it's own global namespace - and from there, custom functions are not accessible:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Add Custom Functions( New Custom Function( "custom", "myfunc", Function( {x}, x + 20 ) ));

project = New Project(
		Run Script(Try(custom:myfunc(1), Caption ("Namespace not accessible")));
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the other hand, it's not possible to run the script a second time inside the project [to create a duplicate custom function in the project scope]. Seems JMP finds the "global" namespace and tries to delete (!!) it:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;project = New Project(
		Run Script(Add Custom Functions( New Custom Function( "custom", "myfunc", Function( {x, y}, x + y - 1 ) )));
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1729494025380.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/69348i7BBFA1516C81F74E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1729494025380.png" alt="hogi_0-1729494025380.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do you use/access custom functions in parallel from standard JMP and from projects?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 10:47:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/807137#M98596</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-10-21T10:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Functions from within Projects</title>
      <link>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/807149#M98597</link>
      <description>&lt;P&gt;Maybe a workaround:&lt;BR /&gt;save a symbol *) in the root namespace (via :::), to access the custom function namespace via the symbol:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;::: custom = New Namespace("custom"	);

// now accessible from everywhere via  :::custom
project = New Project(
		Run Script(Caption(Char(Namespace Exists( ::: custom ))));
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;unfortunately:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Add Custom Functions( New Custom Function( "custom", "myfunc", Function( {x}, x + 20 ) ));

project = New Project(
		Run Script(Try(:::custom:myfunc(1), Caption ("content of the Namespace is not accessible")));
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*) NB: Interesting - the symbol has to have the same name as the namespace (!)&lt;BR /&gt;. What doesn't work:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;::: customNS = New Namespace(	"custom"	);

...

:::customNS:myFunc(1)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;although:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;is namespace(:::customNS)  // -&amp;gt; 1&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2024 10:40:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/807149#M98597</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-10-21T10:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Functions from within Projects</title>
      <link>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/807151#M98598</link>
      <description>&lt;P&gt;Ah, it's not an issue with &lt;STRONG&gt;&lt;EM&gt;custom functions&lt;/EM&gt;&lt;/STRONG&gt;, it seems to be a&amp;nbsp; general issue with &lt;STRONG&gt;Namespaces&lt;/STRONG&gt; and &lt;STRONG&gt;Projects&lt;/STRONG&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;::: myNS = New Namespace("myNS");

:::myNS:x ="success";

caption ("direct: "|| :::myNS:x);
wait(2);
caption(remove);

project = New Project(
		Run Script(Try(Caption("project: " || :::myNS:x), Caption ("fail")));
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Interesting: this is how it works&lt;BR /&gt;... but not very practical&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;project = New Project(Run Script(Try(Caption("project: " || namespace(:::myNS):x), Caption ("fail"))));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2024 10:45:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/807151#M98598</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-10-21T10:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Functions from within Projects</title>
      <link>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/808124#M98756</link>
      <description>&lt;P&gt;I informed JMP Support (# 00170669) and got the feedback that the issues are considered to be a bug:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;:::myNs; // // New Namespace("myNS", ...)
As Root(myNs); // New Namespace("myNS", ...)

//:::myNs:x; // fail in project, works in script window outside project
As Root(myNs):x // success 
Eval(:::myNs):x; // success
Namespace(:::myNs):x; // success&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A wonderful trick: &lt;STRONG&gt;localize the root namespace:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;myVar = :::myNs
myVar:x // success&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;many thanks,&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/1643"&gt;@Jasean&lt;/a&gt;&amp;nbsp;!!! Very smooth, much more practical than &lt;FONT face="courier new,courier"&gt;namespace(:::myNS):x&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 05:28:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/808124#M98756</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-10-25T05:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Functions from within Projects</title>
      <link>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/808125#M98757</link>
      <description>&lt;P&gt;Previous discussion with a similar topic:&lt;/P&gt;&lt;P&gt;&lt;LI-MESSAGE title="Unable to run addins within Project" uid="383815" url="https://community.jmp.com/t5/Discussions/Unable-to-run-addins-within-Project/m-p/383815#U383815" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 05:16:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/808125#M98757</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-10-25T05:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Functions from within Projects</title>
      <link>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/809778#M99108</link>
      <description>&lt;P&gt;I just added the topic to&amp;nbsp;&lt;LI-MESSAGE title="Tiny Traps in Jmp and JSL" uid="702685" url="https://community.jmp.com/t5/Discussions/Tiny-Traps-in-Jmp-and-JSL/m-p/702685#U702685" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;- and bundled the Namespace related topics.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 13:02:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Namespaces-and-Projects/m-p/809778#M99108</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-11-06T13:02:39Z</dc:date>
    </item>
  </channel>
</rss>

