Using variable in message labels... odd problem

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Using variable in message labels... odd problem

Post by Phil Pendlebury » Thu Feb 01, 2007 5:42 pm

Hi there,

To save myself designing tons of different dialogs I am trying to use a simple variable in my dialog:

Code: Select all

Dialog>WaitMessage
   Caption=Track Status Check
   Width=214
   Height=93
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Label=%wait_msg%,6,22,true
   Label=Please Wait!,72,6,true
   Label=This can take some time.,43,38,true
EndDialog>WaitMessage
And example code to display the message:

Code: Select all

Let>wait_msg=Hi there Dum Dum!
Show>WaitMessage
Wait>5
CloseDialog>WaitMessage
However, if I then change the value of the variable and display the dialog again, the message still shows the same (as if the var hasn't changed). For example:

Code: Select all

Let>wait_msg=Hi there Dum Dum!
Show>WaitMessage
Wait>5
CloseDialog>WaitMessage
Let>wait_msg=Gimme some Gum Gum!
Show>WaitMessage
Wait>5
CloseDialog>WaitMessage
Am I missing something obvious? Or is this simply not possible?

I have tried adding "Wait" commands after issuing the "Let>" command in case it took time to stick but it made no difference.

Thanks in advance.

:-)
Phil Pendlebury - Linktree

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Thu Feb 01, 2007 5:58 pm

To change the message in a label you have tell Macro Scheduler which label to change in your case msLabel0, The next label down would be msLabel1 and so on.

With variable "wait_msg"

Code: Select all

Let>wait_msg=Hi there Dum Dum!
Dialog>WaitMessage
   Caption=Track Status Check
   Width=214
   Height=93
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Label=%wait_msg%,6,22,true
   Label=Please Wait!,72,6,true
   Label=This can take some time.,43,38,true
EndDialog>WaitMessage
Show>WaitMessage
Let>wait_msg=Hi there Dum Dum!
let>WaitMessage.msLabel0=%wait_msg%
rda>WaitMessage
Wait>5
Let>wait_msg=Gimme some Gum Gum!
let>WaitMessage.msLabel0=%wait_msg%
rda>WaitMessage
Wait>5
CloseDialog>WaitMessage
Without variable "wait_msg"

Code: Select all

Dialog>WaitMessage
   Caption=Track Status Check
   Width=214
   Height=93
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Label=Hi there Dum Dum!,6,22,true
   Label=Please Wait!,72,6,true
   Label=This can take some time.,43,38,true
EndDialog>WaitMessage
Show>WaitMessage
let>WaitMessage.msLabel0=Hi there Dum Dum!
rda>WaitMessage
Wait>5
let>WaitMessage.msLabel0=Gimme some Gum Gum!
rda>WaitMessage
Wait>5
CloseDialog>WaitMessage

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Thu Feb 01, 2007 6:05 pm

Thank you.

I didn't see this in the manual :? Sorry if I missed it.
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Thu Feb 01, 2007 6:33 pm

OK. Sorry if I am being dumb here but I have tried both of the above and they work perfectly.

However when I place what I need into my code I still have the same problem. I will elaborate and maybe it will make sense...

The way I want this to work is:

Block of code 1 begins
Dialog is displayed here with message 1
Block of code Ends
Dialog closes

More code here

Block of code 2 begins
Dialog is displayed here with message 2
Block of code Ends
Dialog closes

So what I need is actually slightly different from the example given, I thought the example would make it simpler. It's the areas in bold that I can't get right.

Sorry for the confusion, I hope it makes sense.
Phil Pendlebury - Linktree

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

Post by JRL » Thu Feb 01, 2007 7:24 pm

Stealing then altering the code from above:

//Set variable wait_msg
Let>wait_msg=Hi there Dum Dum!

Dialog>WaitMessage
Caption=Track Status Check
Width=214
Height=93
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=1
Resize=0

//apply variable wait_msg in dialog
ONE time only. After this the dialog is defined
//and changing the variable wait_msg will not affect the look of the dialog.

Label=%wait_msg%,6,22,true
Label=Please Wait!,72,6,true
Label=This can take some time.,43,38,true
EndDialog>WaitMessage

Show>WaitMessage
//display the dialog for 3 sec
Wait>3
//After show, the dialog is in use and some of it components are available for redefinition.
//The syntax to redefine the first label is:

let>WaitMessage.msLabel0=Hi there Dum Dum! again!!!
rda>WaitMessage

//Display the updated dialog for 3 sec
Wait>3
Closedialog>WaitMessage

//show nothing for 2 sec for demonstration purposes.
Wait>2

///////Do other stuff

//redefine the dialog then redisplay the dialog
let>WaitMessage.msLabel0=Gimme some Gum Gum!
rda>WaitMessage
show>WaitMessage

//show the dialog for 3 seconds then close
Wait>3
CloseDialog>WaitMessage

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Thu Feb 01, 2007 7:30 pm

Thanks for the detailed explanation, much appreciated. :-)
Phil Pendlebury - Linktree

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