<?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/947686#M109752</link>
    <description>&lt;P&gt;You might also be totally fine with just relying on here namespace if you are running the add-in. It won't work if you run it from the same script window BUT if you run the script from separate script windows, it should.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 May 2026 15:09:35 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2026-05-12T15:09:35Z</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>
    <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/947403#M109734</link>
      <description>&lt;P&gt;Hello thank you for your anwser. I will implement window namespace but the part where I am extracting variable outside the window is a bit difficult as the window name is the same if I run multiple instance&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2026 14:22:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Add-in-Isolating-multiple-instances-with-namespaces/m-p/947403#M109734</guid>
      <dc:creator>SophieCuvillier</dc:creator>
      <dc:date>2026-05-11T14:22:05Z</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/947684#M109751</link>
      <description>&lt;P&gt;One thing that helps here is calling &lt;EM&gt;everything&lt;/EM&gt; from the window rather than starting a script and then asking for input part way through.&amp;nbsp; Even if you don't need user input right away, you could open a window that says 'Starting...', and then in the On Open() script put everything you have before the window today, but with window or local scoped variables.&amp;nbsp; With long scripts this can get out of hand, but then you might consider breaking those into different functions that are defined before the window, or even in different files.&lt;/P&gt;
&lt;P&gt;As an example , the &lt;A href="https://github.com/himanga/JMPValidation" target="_blank"&gt;Validation Column &lt;/A&gt;for time series process data add-in is written this way.&amp;nbsp; Note how UpdateUI is defined in this script on &lt;A href="https://github.com/himanga/JMPValidation/blob/bf3f4e57df7d4530606935d263fa57dcfe24b6c6/AddinFiles/NewValidationColumn.jsl#L274" target="_blank"&gt;line 274&lt;/A&gt; before New Window is called (sorry if that breaks for future readers), and then it is called when a button is pressed on &lt;A href="https://github.com/himanga/JMPValidation/blob/bf3f4e57df7d4530606935d263fa57dcfe24b6c6/AddinFiles/NewValidationColumn.jsl#L670" target="_blank"&gt;line 670&lt;/A&gt;&amp;nbsp;and when other fields are updated.&lt;/P&gt;
&lt;P&gt;Note that this function calls window: variables all over the place - that function's primary purpose is updating the user interface.&amp;nbsp; For most add-ins I do not recommend this, pass all of the info it needs as arguments/parameters and then use all local variables inside the function and only pass results back.&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2026 14:55:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Add-in-Isolating-multiple-instances-with-namespaces/m-p/947684#M109751</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2026-05-12T14:55:47Z</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/947686#M109752</link>
      <description>&lt;P&gt;You might also be totally fine with just relying on here namespace if you are running the add-in. It won't work if you run it from the same script window BUT if you run the script from separate script windows, it should.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2026 15:09:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-Add-in-Isolating-multiple-instances-with-namespaces/m-p/947686#M109752</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-05-12T15:09:35Z</dc:date>
    </item>
  </channel>
</rss>

