Using Variables in Dialogs

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Using Variables in Dialogs

Post by migro » Sat Mar 29, 2008 2:45 pm

Hi together,

I like to use Variables for the dialogtitle (Caption) and also for the Checkboxes.

For all other dialogelements i used, it works well. The Values for the variables are normally stored in a inifile to support the dialog with different languages.

In between i found 1 more place, where variables don't work as i expect:
- If a Variable is used for the text on the Browsebutton the browse dialog won't show up, when clicked.

Codesample:

Code: Select all

LibFunc>user32,GetSystemMetrics,screen_width,0
LibFunc>user32,GetSystemMetrics,screen_height,1
Let>width=450
Let>height=285
Let>left={(%screen_width% div 2) - (%width% div 2)}
Let>top={(%screen_height% div 2) - (%height% div 2)}

Dialog>DSSCdlg
   Caption=%100%
   Top=%top%
   Width=%width%
   Left=%left%
   Height=%height%
   Max=0
   Min=0
   Resize=0
   Label=%101%,16,8,true
   Label=%102%,304,8,true
   ComboBox=strInstanceName,64,8,233,%strInstanceName%
   Button=OK,256,136,75,25,1
   Button=%103%,344,136,75,25,2
   Label=____________________________________________________________________,8,112,true
   Label=%104%,16,104,true
   CheckBox=disclaimer,%105%,16,144,17,False
   Memo=disclaimertext,16,168,409,73,LIABILITY EXCLUSION. ....
   Label=%106%,16,72,true
   Edit=strDBFilePath,96,72,233,%strDBFilePath%
   Button=%107%,344,72,75,25,0
   Edit=strDBName,96,40,201,%strDBName%
   Label=%108%,16,40
   FileBrowse=Browse,strDBFilePath,Dir|*.willneverexist,dir,C:\
EndDialog>DSSCdlg


      Let>Language=English
      Let>WParam=3
      Let>100=DSDBAttach V1.0 - Binds a blank SIRONA Database to a SQL Server
      Let>101=Select:
      Let>102=Quit with "SHIFT + ESC"
      Let>103=Cancel
      Let>104=This tool is only for use with MS SQL-Server 2005 or SQL-Server 2005 Express.
      Let>105=I accept the exclusion of liability:
      Let>106=Database Path:
      Let>107=Browse
      Let>108=Databasename:

Label>MainLoop
   Show>DSSCdlg,result
   If>result=1,Init
   If>result=2,Abbruch
Goto>MainLoop
Thanks in advance, if anybody got some ideas.
Last edited by migro on Thu Apr 03, 2008 8:11 pm, edited 2 times in total.
regards
migro

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Using Variables in Dialogs

Post by migro » Sat Mar 29, 2008 4:23 pm

Sry, made a quote, where i like to edit my first post ...
regards
migro

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

Post by Marcus Tettmar » Thu Apr 03, 2008 9:15 pm

Not sure I follow. I don't have a problem specifying a variable for the browse button text caption.
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
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Thu Apr 03, 2008 9:42 pm

Dear Marcus!

Thanks for the reply.

Specifying a variable for the button caption haven't been the Problem. When used it in this way, the file browsedialog won't show up, when the button is clicked.

The other Problem is specifying a variable for the caption of checkboxes. The text won't show up in the dialog. Its the Variable %105% in the example.

Specifying a variable for the caption of the dialog itself works now. (I've made an error when reading the value from the inifile ;-)
regards
migro

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

Post by Marcus Tettmar » Thu Apr 03, 2008 9:57 pm

My filebrowse still works after using a variable.
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
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Thu Apr 03, 2008 10:21 pm

Have You tried it with the sample code? But anyway the description "Browse" is international. So I will use the browsebuttons caption without localisation.

More important is for me, to use variables for the caption of checkboxes. Does it work on your system?
regards
migro

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

Post by Marcus Tettmar » Thu Apr 03, 2008 10:27 pm

Yes, I tried your sample script above. All works fine. Yes, the caption also works with the variables.
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
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Thu Apr 03, 2008 11:26 pm

When I run the script it looks like the attached screenshot. The value of the variable isn't displayed. I thought i defined it correct with:

Code: Select all

Let>105=I accept the exclusion of liability:
Image

I have no idea what i can do more :?
regards
migro

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Fri Apr 04, 2008 8:10 am

I build a small new testscript using MS V10.023. I would appreciate it, if some of yours can try it out and tell me if it works in your enviroment. I'm really confused because in my enviroments the checkbox won't show the value of the variable "str105".

Code: Select all

Dialog>NGSRdlg
   Caption=Checkbox caption with variable
   Width=445
   Height=118
   Top=134
   Left=287
   Max=0
   Min=0
   Resize=0
   CheckBox=msCheckBox1,%str105%,8,16,393,False
   Button=%str106%,264,48,75,25,1
   Button=%str107%,352,48,75,25,2
EndDialog>NGSRdlg


Let>str105=This is the caption of a checkbox
Let>str106=OK
Let>str107=Cancel


Label>MainLoop
   Show>NGSRdlg,result
   If>result=1,Init
   If>result=2,Exit
Goto>MainLoop


Label>Init
   Message>Do something


Label>Exit
regards
migro

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

Post by Marcus Tettmar » Fri Apr 04, 2008 8:43 am

Yes, I get the same thing. But it works if I set the variable before the Dialog block.
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
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Apr 04, 2008 8:51 am

This will be fixed in next release.
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
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Post by migro » Fri Apr 04, 2008 9:16 am

Thanks a lot for Your help Marcus. Until the next release i declare this variable before the dialog block.

When i do all the declarations before the original dialog block, some elements of the block won't show up anymore or be displayed on the wrong place in the dialog ( Do You got any idea why? ;-)
regards
migro

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