<?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: Get selected item from a list box - changed behavior of JSL? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Get-selected-item-from-a-list-box-changed-behavior-of-JSL/m-p/970767#M110529</link>
    <description>&lt;P&gt;Thanks - as always, much appreciated! It's still puzzling that what is faulty here works in the video linked in my original posting.&lt;/P&gt;</description>
    <pubDate>Sat, 12 Sep 2026 17:27:24 GMT</pubDate>
    <dc:creator>Ressel</dc:creator>
    <dc:date>2026-09-12T17:27:24Z</dc:date>
    <item>
      <title>Get selected item from a list box - changed behavior of JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/Get-selected-item-from-a-list-box-changed-behavior-of-JSL/m-p/970737#M110527</link>
      <description>&lt;P&gt;Currently going through this&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=-lAcq10zDeE&amp;amp;t=515s" target="_self"&gt;&lt;STRONG&gt;beautiful instruction video&lt;/STRONG&gt;&amp;nbsp;on how to write a JSL script by &lt;/A&gt;&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4536"&gt;@David_Burnham&lt;/a&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Up to 07 minutes and 28 seconds everything works as expected. Starting around 8 minutes and 13 seconds, precisely when the window is converted into a modal window, this code here throws an error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// doesn't work:

lst = {"A", "B", "C"};
New Window("Select", &amp;lt;&amp;lt; Modal, 
	Border Box(top(10), bottom(10), left(15), right(10),
		V List  Box(
			TextBox("Select the predictor variable", &amp;lt;&amp;lt;setfontstyle("bold")),
			Spacer Box(size(0,6)),
			lb = List Box(lst)
		)
	)
);
sel = lb &amp;lt;&amp;lt; getSelected;
show(sel);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I found a solution here:&amp;nbsp;&lt;LI-MESSAGE title="How to get specific input values from modal windows to be placed in a JMP script to save." uid="483379" url="https://community.jmp.com/t5/Discussions/How-to-get-specific-input-values-from-modal-windows-to-be-placed/m-p/483379#U483379" 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;At least, when I run the below script and press the "OK" button of the modal window, &lt;FONT face="courier new,courier" color="#0000FF"&gt;sel&amp;nbsp;&lt;/FONT&gt;returns a list with the selected values.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Script&lt;/STRONG&gt;&lt;/U&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// works
NewWindow("Select", &amp;lt;&amp;lt;Modal,
	BorderBox(top(10), bottom(10), left(15), right(10),
	VListBox(
		TextBox("Select the predictor variable", &amp;lt;&amp;lt;setfontstyle("bold")),
		SpacerBox(size(0,6)),
			lb = ListBox(lst),
		
		// Custom buttons to capture selection before closing
			HListBox(
				ButtonBox("OK", sel = lb &amp;lt;&amp;lt; getSelected; show(sel)), 
				ButtonBox("Cancel")
			)
		)
	)
);&lt;/CODE&gt;&lt;CODE class=" language-jsl"&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Sample output&lt;/STRONG&gt;&lt;/U&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;sel = {"A", "B"};
{Button( 1 )}&amp;nbsp;// what&amp;nbsp;is&amp;nbsp;this?&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Three things I would like to understand&lt;/STRONG&gt;&lt;/U&gt;:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Is there something wrong with the original code I've posted at the top (// doesn't work) or has JSL changed behavior since the video was recorded?&lt;/LI&gt;
&lt;LI&gt;The return value &lt;FONT face="courier new,courier" color="#0000FF"&gt;{Button( 1 )}&lt;/FONT&gt;, I don't understand it. Why is it there? I am assuming it comes from the &lt;FONT face="courier new,courier" color="#0000FF"&gt;Button Box()&lt;/FONT&gt; but the scripting index isn't informative.&lt;/LI&gt;
&lt;LI&gt;Am I on the right track with the custom button?&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Edit&lt;/STRONG&gt;&lt;/U&gt;:&lt;/P&gt;
&lt;P&gt;A solution is even in the instruction video.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;lst = {"A", "B", "C"};
NewWindow("Select", &amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;onClose(
		sel = lb &amp;lt;&amp;lt; getSelected;
	),
	BorderBox(top(10), bottom(10), left(15), right(10),
		VListBox(
			TextBox("Select the predictor variable", &amp;lt;&amp;lt;setfontstyle("bold")),
			SpacerBox(size(0,6)),
			lb = ListBox(lst)
		)
	)
);

if (NItems(sel)==0, throw());
;
show(sel);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Sep 2026 18:40:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-selected-item-from-a-list-box-changed-behavior-of-JSL/m-p/970737#M110527</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2026-09-12T18:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Get selected item from a list box - changed behavior of JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/Get-selected-item-from-a-list-box-changed-behavior-of-JSL/m-p/970749#M110528</link>
      <description>&lt;P&gt;1. After modal window closes, you cannot access the values anymore unless they are returned when &amp;lt;&amp;lt; return result is used.&lt;/P&gt;
&lt;P&gt;2. Button(1) just means that the OK was pressed and you can use that for example to control the flow of your script.&lt;/P&gt;
&lt;P&gt;3. Yes, get values when OK is pressed is a good option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I usually try first with &amp;lt;&amp;lt; Return Result and if it doesn't work with my current window, then I get the values when OK button is pressed. I (almost) always add OK and Cancel buttons when modal dialog is being used even though they are not necessary &lt;A href="https://www.jmp.com/support/help/en/19.1/#page/jmp/construct-a-modal-window.shtml" rel="noopener" target="_blank"&gt;Scripting Guide &amp;gt; Display Trees &amp;gt; Modal Windows in JSL &amp;gt; Construct a Modal Window&lt;/A&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;Below is example using &amp;lt;&amp;lt; Return Result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

lst = {"A", "B", "C"};

nw = New Window("Modal Dialog example",
	&amp;lt;&amp;lt;Type("Modal Dialog"),
	&amp;lt;&amp;lt;Return Result,
	V List Box(
		lb = List Box(lst),
		H List Box(
			Button Box("OK"),
			Button Box("Cancel")
		)
	)
);
show(nw);

If(nw["Button"] != 1,
	stop();
);

selvals = nw["lb"];

Show(selvals);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And case where it won't work as you would maybe like to (I want items which are added to collist box, not selected items)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

nw = New Window("Modal Dialog example",
	&amp;lt;&amp;lt;Type("Modal Dialog"),
	&amp;lt;&amp;lt;Return Result,
	H List Box(
		fcs = Filter Col Selector(),
		H List Box(
			Button Box("Add", clb &amp;lt;&amp;lt; append(fcs &amp;lt;&amp;lt; get selected)),
			clb = Col List Box()
		),
		H List Box(
			Button Box("OK",
				selvals = clb &amp;lt;&amp;lt; get items;
			),
			Button Box("Cancel")
		)
	)
);
show(nw);

If(nw["Button"] != 1,
	stop();
);

Show(selvals);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Sep 2026 13:42:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-selected-item-from-a-list-box-changed-behavior-of-JSL/m-p/970749#M110528</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-09-12T13:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get selected item from a list box - changed behavior of JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/Get-selected-item-from-a-list-box-changed-behavior-of-JSL/m-p/970767#M110529</link>
      <description>&lt;P&gt;Thanks - as always, much appreciated! It's still puzzling that what is faulty here works in the video linked in my original posting.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Sep 2026 17:27:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-selected-item-from-a-list-box-changed-behavior-of-JSL/m-p/970767#M110529</guid>
      <dc:creator>Ressel</dc:creator>
      <dc:date>2026-09-12T17:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get selected item from a list box - changed behavior of JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/Get-selected-item-from-a-list-box-changed-behavior-of-JSL/m-p/970779#M110530</link>
      <description>&lt;P&gt;Could be related to older version of JMP and some timings.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Sep 2026 18:07:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-selected-item-from-a-list-box-changed-behavior-of-JSL/m-p/970779#M110530</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-09-12T18:07:47Z</dc:date>
    </item>
  </channel>
</rss>

