<?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 Dynamic list of buttons linked to scripts in a folder in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772601#M95307</link>
    <description>&lt;P&gt;Hey JMP crew!&lt;/P&gt;&lt;P&gt;I was hoping to get some guidance on how I might be able to have a dynamic window with buttons that would link to whatever scripts are in a referenced folder.&amp;nbsp; So if I had two scripts in the folder, I would have a window with two button boxes.&amp;nbsp; If I had 50 then I would have 50 button boxes.&amp;nbsp; Ideally there might be a way to dynamically tell the window how many "columns" to arrange the button boxes in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2024 20:42:17 GMT</pubDate>
    <dc:creator>shampton82</dc:creator>
    <dc:date>2024-07-11T20:42:17Z</dc:date>
    <item>
      <title>Dynamic list of buttons linked to scripts in a folder</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772601#M95307</link>
      <description>&lt;P&gt;Hey JMP crew!&lt;/P&gt;&lt;P&gt;I was hoping to get some guidance on how I might be able to have a dynamic window with buttons that would link to whatever scripts are in a referenced folder.&amp;nbsp; So if I had two scripts in the folder, I would have a window with two button boxes.&amp;nbsp; If I had 50 then I would have 50 button boxes.&amp;nbsp; Ideally there might be a way to dynamically tell the window how many "columns" to arrange the button boxes in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 20:42:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772601#M95307</guid>
      <dc:creator>shampton82</dc:creator>
      <dc:date>2024-07-11T20:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic list of buttons linked to scripts in a folder</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772615#M95309</link>
      <description>&lt;P&gt;Here is a sample using the scripts installed as samples for JMP.&amp;nbsp; The directory reference needs to be changed from JMPPRO to JMP if you do not have JMPPRO.&amp;nbsp; Also the version number 18 needs to be changed to your version number.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dir = "C:\Program Files\JMP\JMPPRO\18\Samples\Scripts";
files = Files In Directory( dir );
For( i = N Items( files ), i &amp;gt;= 1, i--,
	If( Word( -1, files[i], "." ) != "jsl",
		Remove From( files, i, 1 )
	)
);
theExpr = "";
For Each( {scr}, files,
	theExpr = theExpr || ",ButtonBox(\!"" || Word( -2, scr, "./\" ) || "\!", include(\!""
	 || dir || "\" || scr || "\!") )"
);
Eval(
	Parse(
		"nw = New Window( \!"Scripts\!",
			Outline Box( \!"Select Script to Run\!",
				Lineup Box( N Col( 4 )"
		 || theExpr || " )
			)
		);"
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1720735205706.png" style="width: 645px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66087iA3F68D2777007F55/image-dimensions/645x568?v=v2" width="645" height="568" role="button" title="txnelson_0-1720735205706.png" alt="txnelson_0-1720735205706.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I prefer not to use the Eval(Parse()) methodology, however it proved to be too late in the day for me to work through a more readable syntax version.&amp;nbsp; This method does the job.&amp;nbsp; Look for other Community Members to improve on my code.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 22:14:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772615#M95309</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-07-11T22:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic list of buttons linked to scripts in a folder</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772620#M95312</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;You may not feel it is the cleanest code but it works wonderfully!&amp;nbsp; Thanks for the help and quick response!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 22:59:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772620#M95312</guid>
      <dc:creator>shampton82</dc:creator>
      <dc:date>2024-07-11T22:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic list of buttons linked to scripts in a folder</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772644#M95314</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2024-07-12_11-37-07.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66089i5C5236451407C37E/image-size/large?v=v2&amp;amp;px=999" role="button" title="2024-07-12_11-37-07.png" alt="2024-07-12_11-37-07.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 03:39:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772644#M95314</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2024-07-12T03:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic list of buttons linked to scripts in a folder</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772645#M95315</link>
      <description>&lt;P&gt;A bit different version of Jim's code (Filter Each to get list of .jsl files, Eval(EvalExpr()) to append buttons with the paths)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dir = "$SAMPLE_SCRIPTS/";
dir = Convert File Path(dir, windows);

files = Files In Directory(dir);
jslfiles = Filter Each({filename}, files, Word(-1, filename, ".") == "jsl");


// Not sure how you would like to determine column count, but with Lineup box it is fairly easy
lub = Lineup Box(N Col(4));


For Each({filename}, jslfiles,
	Eval(EvalExpr(
		lub &amp;lt;&amp;lt; Append(Button Box(filename,
			nw = New Window(Expr(filename),
				Script Box(Load Text File(Expr(dir || filename)), "JSL", 600, 600)
			);
		));
	));
);


nw = New Window("Scripts in " || dir,
	Outline Box("Click to Open a Script",
		lub	
	);
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;Depending on what you are doing, you might also consider having function/expression which each of the buttons call. Doing it in robust manner does take a bit of extra work though, so knowing how to create these simpler solutions is always a good idea.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 04:19:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772645#M95315</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-12T04:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic list of buttons linked to scripts in a folder</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772774#M95336</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;and &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;If I could pick your brains one more time on this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I wanted to add in a number edit box that had the value for the Line up box and then a button box to press that would apply the value in the number edit box to change the orientation of the script buttons in the window how would that look?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So something like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shampton82_0-1720804211117.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66111iE94A710D1002B418/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shampton82_0-1720804211117.png" alt="shampton82_0-1720804211117.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 17:10:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772774#M95336</guid>
      <dc:creator>shampton82</dc:creator>
      <dc:date>2024-07-12T17:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic list of buttons linked to scripts in a folder</title>
      <link>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772775#M95337</link>
      <description>&lt;P&gt;This might give an idea how you can do it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

init_cols = 4;

dir = "$SAMPLE_SCRIPTS/";
dir = Convert File Path(dir, windows);

files = Files In Directory(dir);
jslfiles = Filter Each({filename}, files, Word(-1, filename, ".") == "jsl");


// Not sure how you would like to determine column count, but with Lineup box it is fairly easy
lub = Lineup Box(N Col(init_cols));


For Each({filename}, jslfiles,
	Eval(EvalExpr(
		lub &amp;lt;&amp;lt; Append(Button Box(filename,
			nw = New Window(Expr(filename),
				Script Box(Load Text File(Expr(dir || filename)), "JSL", 600, 600)
			);
		));
	));
);


nw = New Window("Scripts in " || dir,
	Outline Box("Click to Open a Script",
		V List Box(
			Lineup Box(N Col(2),
				Button Box("Press to update Col count", &amp;lt;&amp;lt; Set Function(function({this}, 
					lub &amp;lt;&amp;lt; N Col((this &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; get)
				))),
				Number Edit Box(init_cols)
			),
			lub	
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Number Edit Box can also trigger on commit (&amp;lt;&amp;lt; Set Function()) / change (&amp;lt;&amp;lt; Set Number Changed()) so you don't necessarily need a button&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 17:32:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Dynamic-list-of-buttons-linked-to-scripts-in-a-folder/m-p/772775#M95337</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-12T17:32:22Z</dc:date>
    </item>
  </channel>
</rss>

