Reloading a dialog

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mduffin
Newbie
Posts: 19
Joined: Fri Nov 12, 2010 4:16 pm

Reloading a dialog

Post by mduffin » Tue Jul 07, 2015 2:15 pm

I have a Dialog script that gets much of it's info from an excel export .xls

Throughout the day there can be new xls to import and I have to close the Dialog and reopen to load the new xls sheet into the dialog.
I'm looking to make a button on the Dialog that will close it and start the script over again instead of restarting the exe.

So here is the button:
object ReloadButton: tMSButton
Left = 864
Top = 3
Width = 48
Height = 25
Caption = 'Reload'
TabOrder = 49
DoBrowse = False
BrowseStyle = fbOpen
end

Here is the dialog handler:
AddDialogHandler>Dialog1,ReloadButton,OnClick,ResetXls

and here is the SRT:
SRT>ResetXls
CloseDialog>Dialog1
SkipLabel>Start2
END>ResetXls

Start2 is a label before the xls file import prompt and before loading the xls to the array and before the Dialog.

When running the script it says that Dialog1 is still running "Line: 55 - A dialog called Dialog1 already exists."

Leading me to think I can use a variable to name Dialog%n% and have the numbers climb up each time you hit the reset button. However if Dialog1 still exists after using the close dialog command, then how will that effect the program after 100 resets?


Is there a way to actually close the dialog if the close dialog command doesn't work? or I'm not understanding how it's intended to be used.

Thank you!

mduffin
Newbie
Posts: 19
Joined: Fri Nov 12, 2010 4:16 pm

Re: Reloading a dialog

Post by mduffin » Thu Jul 09, 2015 10:15 pm

Good news, I found a way reading every thread on this board, I found something that wasn't an answer, but lead me to the answer.

I was using Show>Dialog1,

The comma making a hard stop and yes, leaving the dialog window open to interact with, but also locking me to nothing else.
So, I removed the comma and made a loop after the Show....

Code: Select all

Let>ReDisplayDialogFlag=0
Show>Dialog1

//keep open unless closed or reloaded
Label>Loop
  Wait>0.01
  If>ReDisplayDialogFlag=1
    Goto>DisplayDialog
  EndIf
Goto>Loop

//Close button
SRT>doCancel
      CloseDialog>Dialog1
      Exit>0
END>doCancel

//reload SQL
SRT>ReloadSQL
    Let>ReDisplayDialogFlag=1
    Gosub>ConnectDB
END>ReloadSQL

With Label>DisplayDialog being after the EndDialog> but before all the SetDialogProperty>
So hitting reload sends to load the array from sql server and redraw all the button properties.

Still not sure why closing the dialog with CloseDialog>Dialog1 shuts down the whole script, but it does.

I've also graduated from xlsToArray to SQLToArray, all in two days!!

Thank you Macro Scheduler for allowing a non programmer/coder to make a program!!

Also thank you to viewtopic.php?f=3&t=8673 for finding me viewtopic.php?f=2&t=8472

User avatar
Meryl
Staff
Posts: 124
Joined: Wed Sep 19, 2012 1:53 pm
Location: Texas
Contact:

Re: Reloading a dialog

Post by Meryl » Mon Jul 13, 2015 2:13 pm

Thanks for sharing your experience so it will help others!

mduffin
Newbie
Posts: 19
Joined: Fri Nov 12, 2010 4:16 pm

Re: Reloading a dialog

Post by mduffin » Tue Jul 14, 2015 2:03 pm

Oh sure! I've found so many useful things in these forums, it's a gold mine!! I'm happy to add to that in any way.
Still not sure if leaving a macro to loop all day long has any long term negative effects, but so far so good.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts