<?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: JMP Add-in — Isolating multiple instances with namespaces in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-Add-in-Isolating-multiple-instances-with-namespaces/m-p/946540#M109709</link>
    <description>&lt;P&gt;Easiest option is to use window namespace. I think the second easiest (if we ignore context box) would be to use named namespace IF you can name them. Next would be to utilize one named namespace and collect the values into lists / associative arrays and access those.&amp;nbsp;Anonymous namespaces should also work but these will require some extra work to access correct namespace within the window.&lt;/P&gt;</description>
    <pubDate>Thu, 07 May 2026 17:26:19 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2026-05-07T17:26:19Z</dc:date>
    <item>
      <title>JMP Add-in — Isolating multiple instances with namespaces</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Add-in-Isolating-multiple-instances-with-namespaces/m-p/946492#M109707</link>
      <description>&lt;P&gt;Hi JMP Community,&lt;/P&gt;
&lt;P&gt;I'm building a JMP add-in that creates windows, stores global variables, and calls functions. Everything works fine with a single instance — but when the user launches the add-in twice, the two instances share the same global scope and variables start conflicting (one window overwrites the other's state).&lt;/P&gt;
&lt;P&gt;I initalized my script with Names default to here(1), I have even created my own new space (ns = newspace() ) and put every variables in it but I still do have the conflict. I know about window namespace but I want also to avoid conflict on the variables outside the window&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Launch this script twice — second run breaks the first window

strLabel = "Instance A";
counter = 0;

win = New Window( "Test " || strLabel,
    btn = Button Box( "Click me",
        counter++;
        btn &amp;lt;&amp;lt; Set button name( strLabel || " clicked " || Char( counter ) || "x" );
    )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 May 2026 14:06:54 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Add-in-Isolating-multiple-instances-with-namespaces/m-p/946492#M109707</guid>
      <dc:creator>SophieCuvillier</dc:creator>
      <dc:date>2026-05-07T14:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: JMP Add-in — Isolating multiple instances with namespaces</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Add-in-Isolating-multiple-instances-with-namespaces/m-p/946532#M109708</link>
      <description>&lt;P&gt;If every window is independent then I recommend using the window namespace, designed just for this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1):
//  Functions outside the window are still accessible
rand = function({}, floor(random uniform(10)));

win = New Window("Values",
	show toolbars(0), show menu(0),
	
	// You can put statements above display elements
	window:randomvalue = rand();
	
	v list box(
		text box("Enter a value for this box:"),
		
		// All references to display elements should be in the window namespace
		window:teb = text edit box(""),
		
		// Examples reading and writing values.
		button box("Update random value", window:randomvalue = rand() ),
		button box("Get values from this window",
			window:tb &amp;lt;&amp;lt; Set Text(
				"Random value: " || char(window:randomvalue) ||
				"\!NEntered Value: " || (window:teb &amp;lt;&amp;lt; Get Text)
			)
		),
		window:tb = text box("")
	)
);

// You can get to this from outside the window, but make sure this namespace is protected too - for example from inside another window.
show(win:randomvalue, win:teb &amp;lt;&amp;lt; Get Text);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 May 2026 15:51:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Add-in-Isolating-multiple-instances-with-namespaces/m-p/946532#M109708</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2026-05-07T15:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: JMP Add-in — Isolating multiple instances with namespaces</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-Add-in-Isolating-multiple-instances-with-namespaces/m-p/946540#M109709</link>
      <description>&lt;P&gt;Easiest option is to use window namespace. I think the second easiest (if we ignore context box) would be to use named namespace IF you can name them. Next would be to utilize one named namespace and collect the values into lists / associative arrays and access those.&amp;nbsp;Anonymous namespaces should also work but these will require some extra work to access correct namespace within the window.&lt;/P&gt;</description>
      <pubDate>Thu, 07 May 2026 17:26:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Add-in-Isolating-multiple-instances-with-namespaces/m-p/946540#M109709</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-05-07T17:26:19Z</dc:date>
    </item>
  </channel>
</rss>

