<?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: Local Function Variables in Button Box in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Local-Function-Variables-in-Button-Box/m-p/966106#M110408</link>
    <description>&lt;P&gt;You can use context box&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

make_a_list_box = Function({list_in},
	{Default Local},
	l_box = List Box(list_in);
	Return(l_box);
);

// General Component - Button linked to a specific list box
linked_button_box = Function({button_name, target_list_box},
	{Default Local},
	b_box = Context Box(
		box:target_list_box = target_list_box, 
		Button Box(button_name, 
			Print(box:target_list_box &amp;lt;&amp;lt; Get Items)
		)
	);
	Return(b_box);
);

report_module = Function({list_in, button_name},
	{Default Local},
	report_list = make_a_list_box(list_in);
	report_button = linked_button_box(button_name, report_list);
	report = H List Box(report_list, report_button);
	Print(report_list &amp;lt;&amp;lt; Get Items);
	Return(report);
);

nw = New Window("Test", 
	V List Box(
		report_module({"A", "B", "C"}, "Letter"), 
		report_module({"1", "2", "3"}, "Number")
	)
);

Write();
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 25 Aug 2026 15:55:31 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2026-08-25T15:55:31Z</dc:date>
    <item>
      <title>Local Function Variables in Button Box</title>
      <link>https://community.jmp.com/t5/Discussions/Local-Function-Variables-in-Button-Box/m-p/966087#M110407</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm looking for a solution to accessing local variables when creating a Button Box inside of a function.&amp;nbsp; I've seen one post &lt;A href="https://community.jmp.com/t5/Discussions/Variable-behavior-in-JSL-functions/m-p/55270#M31252" target="_blank" rel="noopener"&gt;here&lt;/A&gt; where the suggested solution was to assign variables to the window namespace.&amp;nbsp; However, I don't think this will work for the reports I am needing to build since they have multiple reused parts in the same window.&lt;/P&gt;
&lt;P&gt;In my example, I just try to print the values of my linked list, but I will want to do a lot more with the final scripts (all functional when testing/cheating using global variables).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
// General Component - List Box
make_a_list_box = Function( {list_in},
	{Default Local},
	l_box = List Box( list_in );
	Return( l_box );
);

// General Component - Button linked to a specific list box
linked_button_box = Function( {button_name, target_list_box},
	{Default Local},
	b_box = Button Box( button_name, Print( target_list_box &amp;lt;&amp;lt; Get Items ) ); // Name Unresolved: target_list_box
	Return( b_box );
);

// Basic Module - Expect multiple in a shared window
report_module = Function( {list_in, button_name},
	{Default Local},
	report_list = make_a_list_box( list_in );
	report_button = linked_button_box( button_name, report_list );
	report = H List Box( report_list, report_button );
	Print( report_list &amp;lt;&amp;lt; Get Items );
	Return( report );
);

// Example Window using multiple modules
New Window( "Test",
	V List Box(
		report_module( {"A", "B", "C"}, "Letter" ),
		report_module( {"1", "2", "3"}, "Number" )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2026 15:20:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Local-Function-Variables-in-Button-Box/m-p/966087#M110407</guid>
      <dc:creator>GavinS</dc:creator>
      <dc:date>2026-08-25T15:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Local Function Variables in Button Box</title>
      <link>https://community.jmp.com/t5/Discussions/Local-Function-Variables-in-Button-Box/m-p/966106#M110408</link>
      <description>&lt;P&gt;You can use context box&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

make_a_list_box = Function({list_in},
	{Default Local},
	l_box = List Box(list_in);
	Return(l_box);
);

// General Component - Button linked to a specific list box
linked_button_box = Function({button_name, target_list_box},
	{Default Local},
	b_box = Context Box(
		box:target_list_box = target_list_box, 
		Button Box(button_name, 
			Print(box:target_list_box &amp;lt;&amp;lt; Get Items)
		)
	);
	Return(b_box);
);

report_module = Function({list_in, button_name},
	{Default Local},
	report_list = make_a_list_box(list_in);
	report_button = linked_button_box(button_name, report_list);
	report = H List Box(report_list, report_button);
	Print(report_list &amp;lt;&amp;lt; Get Items);
	Return(report);
);

nw = New Window("Test", 
	V List Box(
		report_module({"A", "B", "C"}, "Letter"), 
		report_module({"1", "2", "3"}, "Number")
	)
);

Write();
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Aug 2026 15:55:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Local-Function-Variables-in-Button-Box/m-p/966106#M110408</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-08-25T15:55:31Z</dc:date>
    </item>
  </channel>
</rss>

