Error trying to create dialog:

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
billtubbs
Junior Coder
Posts: 32
Joined: Thu Dec 07, 2006 10:00 pm
Location: Vancouver
Contact:

Error trying to create dialog:

Post by billtubbs » Wed Apr 18, 2007 6:10 pm

I am using a dialog box for the first time. The problem only occurs when I put the dialog definition within a loop. It executes fine the first time, the second time around the loop I get the following error message:

"Error trying to create dialog: MyDialog"

In the help on Dialogs there is nothing about where in the code to put the definition code for the Dialog. Should it be in the loop (dialog is redefined each time) or before the loop (only executes once). The error does not occur if I put the dialog definition before the loop. However I want the label text to be different each time, and this does not occur if the dialog code is outside of the loop.

Here is the code:

Code: Select all

Dialog>MyDialog
Caption=Macro scheduler
Max=0
Min=0
Close=0
Resize=0
Left=300
Top=300
Width=200
Height=100
Label=Run reference case simulation for %CRLF%%CountryName% model?,5,5
Button=Yes,10,40,50,20,1
Button=No,70,40,50,20,2
Button=Exit,130,40,50,20,3
EndDialog>MyDialog

Show>MyDialog,result
If>result=3,Stop
If>result=2,SkipRefRun
Anybody know how to avoid the error but have different text in the dialog each time it is displayed? Is there a way to pass a string to a dialog box?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Apr 18, 2007 6:49 pm

Don't put the dialog definition inside the loop. The dialog can only be created once. It can be SHOWN many times, but created once. The dialog block should therefore appear before your loop.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

billtubbs
Junior Coder
Posts: 32
Joined: Thu Dec 07, 2006 10:00 pm
Location: Vancouver
Contact:

Post by billtubbs » Wed Apr 18, 2007 7:03 pm

Thanks, I figured that. It might be worth explaining this on the dialog reference page.

So does this mean all dialogs static? You can't have the same dialog show different label text and you can't pass variables to a dialog?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Apr 18, 2007 7:12 pm

No dialogs are not static, you can change captions and values at runtime.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Apr 18, 2007 7:59 pm

Bill,
Here's a simple dialog that updates. It is a button that updates but the concept is the same for labels.

Code: Select all

GetTime>ttime
ScreenCapture>-1000,-1000,-888,-888,%TEMP_DIR%~~WhiteSpace.jpg
Dialog>MyDialog
   Caption=           Time
   Width=112
   Height=60
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=0
   Resize=0
   Image=%TEMP_DIR%~~WhiteSpace.jpg,0,0,112,60
   Button=ttime,14,6,75,25,2
EndDialog>MyDialog

Show>MyDialog
IfFileExists>%TEMP_DIR%~~WhiteSpace.jpg
  DeleteFile>%TEMP_DIR%~~WhiteSpace.jpg
EndIf

Label>start
  GetDialogAction>MyDialog,r
  If>r=2,End
  GetTime>ttime
  Let>MyDialog.MSBUTTON1=%ttime%
  ResetDialogAction>MyDialog
  Wait>0.1
Goto>start

Label>End

billtubbs
Junior Coder
Posts: 32
Joined: Thu Dec 07, 2006 10:00 pm
Location: Vancouver
Contact:

Post by billtubbs » Wed Apr 18, 2007 8:15 pm

Thanks JRL
that does the trick.
Bill.

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