<?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 How to show modal window which running script after it is open? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/762921#M94339</link>
    <description>&lt;P&gt;I spend some time created a jsl script, which provide user interface to specify some criteria and pull data from Amazon Redshift based on user input. The script is working well but having a small issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once user clicks on query button on a modal window, it set a variable isValid = 1, close itself to execute subsequent script, which will then create a progress window that display message like "pulling data, please wait..." and starting the query on open. It should close itself after the query is done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is, this progress window cannot be see (not showing up) on my screen. It seems like JMP run the query script immediately after the window was created before it is being bring to front, although the query is successful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to insert wait(0) or bring window to front before query script, still no luck. I can only see the progress window only if I remark the query part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I can do to make the window show up and running query script at the same time?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/*scripts before this line are not related to the issue, hence not included*/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If(isValid == 1, 
	nwQuery = New Window( "Query", &amp;lt;&amp;lt;Show Menu( 0 ), &amp;lt;&amp;lt;Show Toolbars( 0 ), &amp;lt;&amp;lt; Modal,
		Lineup Box(N Col(2), Busy Light(&amp;lt;&amp;lt; Automatic, size(40,40)), Text Box("Pulling data, please wait...")),
		bbOk = Button Box("Ok", &amp;lt;&amp;lt; Visibility("Collapse"), &amp;lt;&amp;lt; Set Function(Function({thisBox},
			Wait(0);
            /* some action in preparing query criteria &lt;BR /&gt;               window show up if remark below lines */
			mySQL = Eval Insert(tpSQL);
			dbc = Create Database Connection("DSN=Amazon Redshift; UID=***; PSW=***");
			dt = Execute SQL (dbc, mySQL, "Query");
			close database connection(dbc);&lt;BR /&gt;            // add wait(2); if remark above lines
			bbOk &amp;lt;&amp;lt; Close Window;			
		))),
        bbOk &amp;lt;&amp;lt; Click;
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 08 Jun 2024 09:19:00 GMT</pubDate>
    <dc:creator>Toy</dc:creator>
    <dc:date>2024-06-08T09:19:00Z</dc:date>
    <item>
      <title>How to show modal window which running script after it is open?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/762921#M94339</link>
      <description>&lt;P&gt;I spend some time created a jsl script, which provide user interface to specify some criteria and pull data from Amazon Redshift based on user input. The script is working well but having a small issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once user clicks on query button on a modal window, it set a variable isValid = 1, close itself to execute subsequent script, which will then create a progress window that display message like "pulling data, please wait..." and starting the query on open. It should close itself after the query is done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is, this progress window cannot be see (not showing up) on my screen. It seems like JMP run the query script immediately after the window was created before it is being bring to front, although the query is successful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to insert wait(0) or bring window to front before query script, still no luck. I can only see the progress window only if I remark the query part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I can do to make the window show up and running query script at the same time?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/*scripts before this line are not related to the issue, hence not included*/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If(isValid == 1, 
	nwQuery = New Window( "Query", &amp;lt;&amp;lt;Show Menu( 0 ), &amp;lt;&amp;lt;Show Toolbars( 0 ), &amp;lt;&amp;lt; Modal,
		Lineup Box(N Col(2), Busy Light(&amp;lt;&amp;lt; Automatic, size(40,40)), Text Box("Pulling data, please wait...")),
		bbOk = Button Box("Ok", &amp;lt;&amp;lt; Visibility("Collapse"), &amp;lt;&amp;lt; Set Function(Function({thisBox},
			Wait(0);
            /* some action in preparing query criteria &lt;BR /&gt;               window show up if remark below lines */
			mySQL = Eval Insert(tpSQL);
			dbc = Create Database Connection("DSN=Amazon Redshift; UID=***; PSW=***");
			dt = Execute SQL (dbc, mySQL, "Query");
			close database connection(dbc);&lt;BR /&gt;            // add wait(2); if remark above lines
			bbOk &amp;lt;&amp;lt; Close Window;			
		))),
        bbOk &amp;lt;&amp;lt; Click;
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Jun 2024 09:19:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/762921#M94339</guid>
      <dc:creator>Toy</dc:creator>
      <dc:date>2024-06-08T09:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to show modal window which running script after it is open?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/762922#M94340</link>
      <description>&lt;P&gt;You don't need to use modal window to show that query is running. Use normal window, open it before the query starts and close it when the query finishes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
isValid = 1;

If(isValid == 1,
	nw = New Window("Query",
		&amp;lt;&amp;lt;Show Menu(0),
		&amp;lt;&amp;lt;Show Toolbars(0),
		Lineup Box(N Col(2), Busy Light(&amp;lt;&amp;lt;Automatic, size(40, 40)), Text Box("Pulling data, please wait...")),
	);
	wait(0);

	mySQL = Eval Insert(tpSQL);
	dbc = Create Database Connection("DSN=Amazon Redshift; UID=***; PSW=***");
	dt = Execute SQL(dbc, mySQL, "Query");
	Close Database Connection(dbc);
	
	nw &amp;lt;&amp;lt; Close Window();
	
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also I suggest you move from Create Database connection, Execute SQL, Close database connection to New SQL Query as it is the preferred method in for queries (it is more annoying to use, has lacking documentation but still... it is the way going forward).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;If you decide to move to New SQL Query() remember to use &amp;lt;&amp;lt; Run Foreground with it IF you wish the script wait for the query to finish.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2024 09:35:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/762922#M94340</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-06-08T09:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to show modal window which running script after it is open?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/762946#M94350</link>
      <description>The reason to use modal window is it will be display on the center of screen and it suppose to be show on top by default. I tried normal window before and it is not show up too.&lt;BR /&gt;&lt;BR /&gt;Anyway, I'll go and gather more info and explore the new sql query method. Will reply you again after that.&lt;BR /&gt;&lt;BR /&gt;Much appreciated for your valuable opinion and suggestion, thanks!</description>
      <pubDate>Sun, 09 Jun 2024 06:21:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/762946#M94350</guid>
      <dc:creator>Toy</dc:creator>
      <dc:date>2024-06-09T06:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to show modal window which running script after it is open?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/764904#M94428</link>
      <description>&lt;P&gt;After some try and error, I figure out some code to make the script behavior in the way that I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As your suggestion, I make use of normal window to show that query is running + New SQL Query function. Since the normal window will not popup at the center of screen, I create a function to capture monitor screen size (don't want to call external power shell script for that) then calculate where it should be appear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;However, there is a small shortcoming -- the busy light box does not spin when query is running -- nothing we can do about it, right?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

GetWinConsoleSize = Function({},
	nW = New Window("Get Win Console Size", &amp;lt;&amp;lt; Window View("Invisible"), &amp;lt;&amp;lt; Maximize Window(1));
	theSize = nW &amp;lt;&amp;lt; Get Window Size();
	nW &amp;lt;&amp;lt; Close Window();
	Return(theSize);
);

drawWinProgress = Function({scrSize},
    xSize = 250;
    ySize = 50;
	cpX = (scrSize[1]/2)-(xSize/2);
	cpY = (scrSize[2]/2)-(ySize/2);
	nW = New Window("Query Data", &amp;lt;&amp;lt; Show Menu(0), &amp;lt;&amp;lt; Show Toolbars(0), &amp;lt;&amp;lt; Size(xSize,ySize), &amp;lt;&amp;lt; Show Window (0),
		Lineup Box(N Col(2), Busy Light(&amp;lt;&amp;lt; Automatic, size(40,40)), Text Box("  Pulling data, please wait ...")),
	);
	nW &amp;lt;&amp;lt; Move Window(cpX, cpY);
	nW &amp;lt;&amp;lt; Show Window (1);
	Return(nW);
);

nwMain = New Window("UI for user to input query criteria", &amp;lt;&amp;lt; Modal, &amp;lt;&amp;lt; Return Result,
  // All display box goes here
	H List Box(
		Spacer Box(),
		bbQuery  = Button Box("Query",  
		isValid = 1;
		bbQuery &amp;lt;&amp;lt; Close Window;
		,
		isValid = 0;
		bbCancel = Button Box("Cancel", Stop()),
	),
);

If(isValid == 1, 
    wcSize = GetWinConsoleSize();
	wProg = drawWinProgress(wcSize);
	Wait(0);&lt;BR /&gt;    // Generating SQL based on user criteria
    dt = New SQL Query(Connection(strOdbcConnection), CustomSQL(mySQL)) &amp;lt;&amp;lt; Run Foreground;
    wProg &amp;lt;&amp;lt; Close Window;
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 07:44:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/764904#M94428</guid>
      <dc:creator>Toy</dc:creator>
      <dc:date>2024-06-12T07:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to show modal window which running script after it is open?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/764949#M94434</link>
      <description>&lt;P&gt;You could use &amp;lt;&amp;lt; Run Background but it would come with a lot of different problems you would have to solve.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 08:03:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/764949#M94434</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-06-12T08:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to show modal window which running script after it is open?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/765100#M94455</link>
      <description>&lt;P&gt;&lt;EM&gt;Also I suggest you move from Create Database connection, Execute SQL, Close database connection to New SQL Query as it is the preferred method in for queries (it is more annoying to use, has lacking documentation but still... it is the way going forward).&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I use create database connection/execute sql/close database connection because often I have numerous SQL queries to execute.&amp;nbsp; There is overhead involved to create the database connection.&amp;nbsp; Calling New SQL Query multiple times could be slower.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I'm curious why you think New SQL Query is the way forward?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 15:21:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/765100#M94455</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2024-06-12T15:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to show modal window which running script after it is open?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/765126#M94461</link>
      <description>&lt;P&gt;My suggestion is based on this post &lt;LI-MESSAGE title="Which way to go query database?" uid="652420" url="https://community.jmp.com/t5/Discussions/Which-way-to-go-query-database/m-p/652420#U652420" 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;and the comment by Brian. I don't really like using New SQL Query() due to many many problems it has but still, I'm moving more and more of my scripts to use it to hopefully future-proof my scripts.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2024 15:39:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/765126#M94461</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-06-12T15:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to show modal window which running script after it is open?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/765321#M94492</link>
      <description>&lt;P&gt;I use new sql query() all the time, because functionality is the best for most of my scripts, and JMP recommends it as "right way". Perhaps it would be worth to write a list of Pro's and Con's and use this as a hint for future development, e.g. put it to the wish list. Why not to enhance new sql query() for more than one statement.&lt;/P&gt;&lt;P&gt;Perhaps we can talk about in Scripters Club.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 06:11:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/765321#M94492</guid>
      <dc:creator>Georg</dc:creator>
      <dc:date>2024-06-13T06:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to show modal window which running script after it is open?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/765345#M94501</link>
      <description>&lt;P&gt;We have at least one wish list item&amp;nbsp;&lt;LI-MESSAGE title="improve documentation on &amp;amp;quot;new sql query()&amp;amp;quot;" uid="655029" url="https://community.jmp.com/t5/JMP-Wish-List/improve-documentation-on-quot-new-sql-query-quot/m-p/655029#U655029" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;but there are definitely few more that would be needed. Collecting the frustrations and issues is a good idea (I think I have made some posts regarding those earlier).&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 10:08:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-show-modal-window-which-running-script-after-it-is-open/m-p/765345#M94501</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-06-13T10:08:19Z</dc:date>
    </item>
  </channel>
</rss>

