<?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 Integrating a Query Builder script (with a post-query script) into another script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Integrating-a-Query-Builder-script-with-a-post-query-script-into/m-p/56162#M31525</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've&amp;nbsp;been using&amp;nbsp;query builder and graph builder to put together some scripts that constantly pull data off a server, plot, and save results (in JMP 13). Recently, I've been trying to tie several of these scripts into a single script that runs all of them at once using Include(), which works fine. The problem I'm facing now is all the directories have been hard coded, and I'd like to use something like: Get Default Directory() so that this broader collection of scripts can be moved onto other computers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately,&amp;nbsp;I've run into the following problems:&lt;/P&gt;
&lt;P&gt;-When Get Default Directory() is used within the 'Post-Query Script' it returns&amp;nbsp; '/ ' , no matter where this script is saved.&lt;/P&gt;
&lt;P&gt;-When saving data tables/graphs created in the post-query script that to variables, those variables don't seem to exist (or are not accessible) outside of the&lt;/P&gt;
&lt;P&gt;post-query script.&lt;/P&gt;
&lt;P&gt;-Any variables created outside of the post-query script cannot be used inside it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Main File

directory = Get Default Directory();

fileNames = Files In Directory( directory );

For( iFile = 1, iFile &amp;lt;= N Items( fileNames ), iFile++, 

	filename = fileNames[iFile];

	If( Ends With( filename, ".jsl" ), 

		Include( directory || script_folder || filename, invisible );

	);

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Example Post-Query File section

gb = Graph Builder( 
     // graph details

);
// directory = Get Default Directory(); // Another method attempted

myPath = directory || "Report\";
myName = "Example";
fileName = myPath || myName || ".pptx";
myTemplate = directory || "Template.pptx";

Report( gb ) &amp;lt;&amp;lt; save presentation( fileName, Template( myTemplate ), Outline Titles( "Hide" ) );

gb &amp;lt;&amp;lt; close window;
Close All( data tables );
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any thoughts?&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 23:24:55 GMT</pubDate>
    <dc:creator>aserino</dc:creator>
    <dc:date>2023-06-09T23:24:55Z</dc:date>
    <item>
      <title>Integrating a Query Builder script (with a post-query script) into another script</title>
      <link>https://community.jmp.com/t5/Discussions/Integrating-a-Query-Builder-script-with-a-post-query-script-into/m-p/56162#M31525</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've&amp;nbsp;been using&amp;nbsp;query builder and graph builder to put together some scripts that constantly pull data off a server, plot, and save results (in JMP 13). Recently, I've been trying to tie several of these scripts into a single script that runs all of them at once using Include(), which works fine. The problem I'm facing now is all the directories have been hard coded, and I'd like to use something like: Get Default Directory() so that this broader collection of scripts can be moved onto other computers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately,&amp;nbsp;I've run into the following problems:&lt;/P&gt;
&lt;P&gt;-When Get Default Directory() is used within the 'Post-Query Script' it returns&amp;nbsp; '/ ' , no matter where this script is saved.&lt;/P&gt;
&lt;P&gt;-When saving data tables/graphs created in the post-query script that to variables, those variables don't seem to exist (or are not accessible) outside of the&lt;/P&gt;
&lt;P&gt;post-query script.&lt;/P&gt;
&lt;P&gt;-Any variables created outside of the post-query script cannot be used inside it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Main File

directory = Get Default Directory();

fileNames = Files In Directory( directory );

For( iFile = 1, iFile &amp;lt;= N Items( fileNames ), iFile++, 

	filename = fileNames[iFile];

	If( Ends With( filename, ".jsl" ), 

		Include( directory || script_folder || filename, invisible );

	);

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Example Post-Query File section

gb = Graph Builder( 
     // graph details

);
// directory = Get Default Directory(); // Another method attempted

myPath = directory || "Report\";
myName = "Example";
fileName = myPath || myName || ".pptx";
myTemplate = directory || "Template.pptx";

Report( gb ) &amp;lt;&amp;lt; save presentation( fileName, Template( myTemplate ), Outline Titles( "Hide" ) );

gb &amp;lt;&amp;lt; close window;
Close All( data tables );
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any thoughts?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:24:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Integrating-a-Query-Builder-script-with-a-post-query-script-into/m-p/56162#M31525</guid>
      <dc:creator>aserino</dc:creator>
      <dc:date>2023-06-09T23:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Integrating a Query Builder script (with a post-query script) into another script</title>
      <link>https://community.jmp.com/t5/Discussions/Integrating-a-Query-Builder-script-with-a-post-query-script-into/m-p/56173#M31530</link>
      <description>&lt;P&gt;Adding another example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dir = Get Default Directory();
query = Open( dir || "query.jmpquery", Private );
query &amp;lt;&amp;lt; Run(
	On Run Complete(
		queryResult &amp;lt;&amp;lt; // some function
		a = 1
	)
);
Write( a );  //  variable is unknown&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Creating a variable inside Run() isn't accessible outside of Run()&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 15:12:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Integrating-a-Query-Builder-script-with-a-post-query-script-into/m-p/56173#M31530</guid>
      <dc:creator>aserino</dc:creator>
      <dc:date>2018-05-02T15:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Integrating a Query Builder script (with a post-query script) into another script</title>
      <link>https://community.jmp.com/t5/Discussions/Integrating-a-Query-Builder-script-with-a-post-query-script-into/m-p/56179#M31534</link>
      <description>&lt;P&gt;Your post contains several items to address:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;If you are working on Windows, Get Default Directory(), is not getting the last directory used. If your program prompts, use Set Default Directory, then Get Default Directory() will return this value.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;I recommend using a namespace or a global Associative Array, to maintain references/variables.&amp;nbsp; If more than one instance of your program is running at any one time, make it an anonymous namespace, so that it is unique for each instance.&amp;nbsp; For an associative array, ::varRef_aa = Associative Array(); ::varRef_aa &amp;lt;&amp;lt; Set Default Value(-9999);&amp;nbsp; Then in your script specify ::varRef_aa[a] = 1;&amp;nbsp; A benefit of using a NameSpace is that an unintended Clear Globals() does not delete the namespace nor its contents.&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;I am not a fan of Save Presentation because every object is saved on a different page and there is very little control for scaling. I use a free external program called &lt;A href="https://p3icli.sourceforge.io/jsl_example.html" target="_self"&gt;P3ICLI&lt;/A&gt;. So typically, I create an output directory, unique for the task or report, then save the view that I want to a picture in that directory. I am bringing up his method, because by saving the output you want, as slide 1, 2, etc. , you &lt;EM&gt;&lt;STRONG&gt;&lt;U&gt;can&lt;/U&gt; &lt;/STRONG&gt;&lt;/EM&gt;use Save Presentation, by creating a list of Files in Directory()&amp;nbsp; for that that saved directory,&amp;nbsp; and in a for loop appending them to your PPTX using Save Presentation. Also, by saving a picture, you could have a multi-object display, saved and when using Save Presentation, all items are on the same page.&amp;nbsp; It offers some control of the PPTX report.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally, yes, it is annoying that Open Database(connect_str, ...) and Create Database Connection(connect_str) can use the same connect string that requires the trailing slash, yet New SQL Query() requires the trailing slash be removed and a prefix of ODBC: if connecting to a database.&lt;/P&gt;&lt;PRE&gt;//--- Method 3: New SQL Query platform script -----------------------------------
//remove the trailing slash on importpath
importnoslash = substr(connect_str, 1, length(connect_str)-1 ); 
nconnect = "ODBC:" || importnoslash&lt;/PRE&gt;&lt;P&gt;Just a few ideas.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 May 2018 09:06:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Integrating-a-Query-Builder-script-with-a-post-query-script-into/m-p/56179#M31534</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-05-01T09:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Integrating a Query Builder script (with a post-query script) into another script</title>
      <link>https://community.jmp.com/t5/Discussions/Integrating-a-Query-Builder-script-with-a-post-query-script-into/m-p/56181#M31535</link>
      <description>&lt;P&gt;You should consider creating an addin for your application.&amp;nbsp; That will solve your problem of where the files are located.&amp;nbsp; An addin associates an alias with a file location.&amp;nbsp; If your addin "alias" is com.company.dept.mygreatapp, you can refer to files like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;include("$ADDIN_HOME(com.company.dept.mygreatapp)\DoSomethingGreat.jsl");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 May 2018 12:41:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Integrating-a-Query-Builder-script-with-a-post-query-script-into/m-p/56181#M31535</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-05-01T12:41:06Z</dc:date>
    </item>
  </channel>
</rss>

