Cannot use Dialog in SRT
Moderators: Dorian (MJT support), JRL
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Cannot use Dialog in SRT
I had created the following script as an example of using Caption property in Dialog. It is supposed to cycle through the two error examples and end. But it did not work and I found that when the Dialog Name is visited a second time, the macro halts with the message "The component named "DialogName" already exists".
I made some changes to cycle through the two error messages using a count and an if to do error1, go to the subroutine, check the count to then use Goto to do error2, but also got the same error message.. So it is not caused by SRT or Goto, it is somehow inherent in Dialog. It does not seem practical to make separate Dialogs for every need, especially with the ability to use variables to modifiy its properties. We should be able to reuse a dialog on demand. This is a great feature in 7.2, it will justify the purchase of the compiler version.
Sample script that fails:
=============================
Label>Error1
Let>ErrorCaption=something line 'Warning'
Let>WarningHelp=This is the message for Error 1
GoSub>MessageWindow
Label>Error2
Let>ErrorCaption=Another Phrase like LOSER!
Let>WarningHelp=This is the message for Error 2
GoSub>MessageWindow
Goto>End
Label>ErrorMessages
SRT>MessageWindow
Dialog>MyNewWindow
Caption=%ErrorCaption%
Top=144
Width=250
Left=312
Height=150
Label=%WarningHelp%,34,30
Button=OK,28,80,75,25,1
Button=Cancel,120,80,75,25,2
EndDialog>MyNewWindow
PlayWav>Alarm.wav
Show>MyNewWindow,result
End>MessageWindow
Label>End
============================
Did I miss something here, or is a patch needed?
I made some changes to cycle through the two error messages using a count and an if to do error1, go to the subroutine, check the count to then use Goto to do error2, but also got the same error message.. So it is not caused by SRT or Goto, it is somehow inherent in Dialog. It does not seem practical to make separate Dialogs for every need, especially with the ability to use variables to modifiy its properties. We should be able to reuse a dialog on demand. This is a great feature in 7.2, it will justify the purchase of the compiler version.
Sample script that fails:
=============================
Label>Error1
Let>ErrorCaption=something line 'Warning'
Let>WarningHelp=This is the message for Error 1
GoSub>MessageWindow
Label>Error2
Let>ErrorCaption=Another Phrase like LOSER!
Let>WarningHelp=This is the message for Error 2
GoSub>MessageWindow
Goto>End
Label>ErrorMessages
SRT>MessageWindow
Dialog>MyNewWindow
Caption=%ErrorCaption%
Top=144
Width=250
Left=312
Height=150
Label=%WarningHelp%,34,30
Button=OK,28,80,75,25,1
Button=Cancel,120,80,75,25,2
EndDialog>MyNewWindow
PlayWav>Alarm.wav
Show>MyNewWindow,result
End>MessageWindow
Label>End
============================
Did I miss something here, or is a patch needed?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Treat the "Dialog ... EndDialog" section like a declaration - put it at the top of your script, like you would a vbscript sub:
Dialog>MyNewWindow
[..]
EndDialog>MyNewWindow
Label>Error1
[.. etc...]
Label>ErrorMessages
SRT>MessageWindow
PlayWav>Alarm.wav
Show>MyNewWindow,result
End>MessageWindow
Label>End
Unfortunately, it seems that you've discovered that a Dialog "Caption=" and a Label can't have variables in their caption property.
Also I tried doing the same, using a button instead of a label. It uses the first custom text, but not the second.
Dialog>MyNewWindow
[..]
EndDialog>MyNewWindow
Label>Error1
[.. etc...]
Label>ErrorMessages
SRT>MessageWindow
PlayWav>Alarm.wav
Show>MyNewWindow,result
End>MessageWindow
Label>End
Unfortunately, it seems that you've discovered that a Dialog "Caption=" and a Label can't have variables in their caption property.
Also I tried doing the same, using a button instead of a label. It uses the first custom text, but not the second.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Good suggestion to move to the top. That solves the problem of multiple Dialog calls. No mention in Help of that as a requirement, but makes sense. But if I move Dialog to top, it does allow multiple calls of the same Dialog but then the variables don't work.
Contrary to your observation about variables in Caption, that does work. Here is an example:
Label>Error1
Let>ErrorCaption=something line 'Warning'
Let>WarningHelp=This is the message for Error 1
Dialog>MyNewWindow
Caption=%ErrorCaption%
Top=144
Width=250
Left=312
Height=150
Label=%WarningHelp%,34,30
Button=OK,28,80,75,25,1
Button=Cancel,120,80,75,25,2
EndDialog>MyNewWindow
Show>MyNewWindow
If the Dialog is in the center then varaibles do work for Caption and Labels. But that does not allow multiple calls of the same Dialog!
I tried setting variables at top before Dialog at top, but variables did not work in Dialog.
I tried setting variables at top after Dialog at top, but variables did not work in Dialog.
So we see that we have an OR Condition
1. Define Dialog at top to have multiple calls to the Dialog
OR
2. Define variables, Dialog, ShowDialog as a group to use variables in Dialog.
We can have or the other, but not both. Needs to be corrected, see no practical work around.
Contrary to your observation about variables in Caption, that does work. Here is an example:
Label>Error1
Let>ErrorCaption=something line 'Warning'
Let>WarningHelp=This is the message for Error 1
Dialog>MyNewWindow
Caption=%ErrorCaption%
Top=144
Width=250
Left=312
Height=150
Label=%WarningHelp%,34,30
Button=OK,28,80,75,25,1
Button=Cancel,120,80,75,25,2
EndDialog>MyNewWindow
Show>MyNewWindow
If the Dialog is in the center then varaibles do work for Caption and Labels. But that does not allow multiple calls of the same Dialog!
I tried setting variables at top before Dialog at top, but variables did not work in Dialog.
I tried setting variables at top after Dialog at top, but variables did not work in Dialog.
So we see that we have an OR Condition
1. Define Dialog at top to have multiple calls to the Dialog
OR
2. Define variables, Dialog, ShowDialog as a group to use variables in Dialog.
We can have or the other, but not both. Needs to be corrected, see no practical work around.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Robert,
You can use variables within Dialogs and have the dialog declared at the top. However you can't use a variable for the dialog caption.
The dialog block is used to CREATE a dialog. The Show command SHOWS it. You can't create one thing more than once. It either exists or it doesn't. So you can only have one Dialog block per dialog. That is all you need. You can show it as many times as you like. The help documentation does say that the dialog block is used to create dialogs which must be displayed LATER in the script with the Show command.
Here is a simple example which uses a dialog and subroutines and lets you change the default value of text with a variable declared AFTER the dialog is created:
Dialog>Send
Caption=Send Message
Top=270
Width=358
Left=222
Height=298
Label=To,8,8
Label=Subject,8,32
Edit=txtTo,64,8,273,
Edit=txtSubject,64,32,273,
Memo=txtMsg,8,56,329,177,%DefVal%,
Button=Send,8,240,75,25,1
Button=Cancel,88,240,75,25,2
EndDialog>Send
Let>server=mail.server.com
Let>myemail=[email protected]
Let>me=My Name
Gosub>Test
SRT>Test
Let>DefVal=Hi
Show>Send,res
if>res=1,sendmail
End>Test
SRT>sendmail
SMTPSendMail>txtTo,server,myemail,me,txtDubject,txtMsg,
MessageModal>SMTP_RESULT
END>sendmail
As you can see this exhibits a simple email sender app.
You can use variables within Dialogs and have the dialog declared at the top. However you can't use a variable for the dialog caption.
The dialog block is used to CREATE a dialog. The Show command SHOWS it. You can't create one thing more than once. It either exists or it doesn't. So you can only have one Dialog block per dialog. That is all you need. You can show it as many times as you like. The help documentation does say that the dialog block is used to create dialogs which must be displayed LATER in the script with the Show command.
Here is a simple example which uses a dialog and subroutines and lets you change the default value of text with a variable declared AFTER the dialog is created:
Dialog>Send
Caption=Send Message
Top=270
Width=358
Left=222
Height=298
Label=To,8,8
Label=Subject,8,32
Edit=txtTo,64,8,273,
Edit=txtSubject,64,32,273,
Memo=txtMsg,8,56,329,177,%DefVal%,
Button=Send,8,240,75,25,1
Button=Cancel,88,240,75,25,2
EndDialog>Send
Let>server=mail.server.com
Let>myemail=[email protected]
Let>me=My Name
Gosub>Test
SRT>Test
Let>DefVal=Hi
Show>Send,res
if>res=1,sendmail
End>Test
SRT>sendmail
SMTPSendMail>txtTo,server,myemail,me,txtDubject,txtMsg,
MessageModal>SMTP_RESULT
END>sendmail
As you can see this exhibits a simple email sender app.
MJT Net Support
[email protected]
[email protected]
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
(This is Bob, not Robert)
OK, think I have it. Variables can legally only be used for Edit And Memo fields. But I hope you can understand my confusion when I am actually able to use variables in Captions and Labels See this example.
From the Dialog Help:
And since I was able to do it, I guess I have been spoiled now. It is nice to be able to customize the Dialog programatically. I suspect I can do the same thing with the values of the Size and Position parameters and captions on Buttons also, but have not tried that yet. If this is a bug, can't we have it as a feaure instead?
Can this capabliity be added to future release? And still be able to be called in SRT.
PLEASE? and Thank You.
OK, think I have it. Variables can legally only be used for Edit And Memo fields. But I hope you can understand my confusion when I am actually able to use variables in Captions and Labels See this example.
======================//Using Input for testing, but %Code% could be set by other conditions earlier in the script, such as specific error codes.
Input>Code,Enter the error number: ( 1 / 2 / 3 )
Let>Step=Step%Code%
Goto>%Step%
Label>Step1
Let>WarningHelp=This is your FIRST WARNING!
Let>ErrorCaption= WARNING NOTICE!
Let>Sound=c:\windows\media\chimes.wav
Goto>Error
Label>Step2
Let>WarningHelp=Can't you stop making mistakes?
Let>ErrorCaption=YOU ARE A LOSER
Let>Sound=c:\windows\media\chord.wav
Goto>Error
Label>Step3
Let>WarningHelp=Uh Oh! You are about to be Fired!
Let>ErrorCaption=THIS IS 30 DAYS NOTICE!
Let>Sound=c:\windows\media\notify.wav
Goto>Error
Label>Error
Dialog>WarningWindow
Caption=%ErrorCaption%
Top=144
Width=250
Left=312
Height=150
Label=%WarningHelp%,34,30
Button=OK,28,80,75,25,1
Button=Cancel,120,80,75,25,2
EndDialog>WarningWindow
PlayWav>%Sound%
Show>WarningWindow,result
Goto>End
Label>End
From the Dialog Help:
. It does not demand that it be like a declaration at the very top. This only tells me that Show> must follow Dialog>. But there is nothing to say that Dialog> and Show> cannot be in the middle or the end of a script. I am inferring from your response, and the need to call multiple times, that it must be at the top and that is why my earlier sample with Caption and Label variables should not work?A dialog block is used to create a dialog which can be displayed later in the script with the Show command.
And since I was able to do it, I guess I have been spoiled now. It is nice to be able to customize the Dialog programatically. I suspect I can do the same thing with the values of the Size and Position parameters and captions on Buttons also, but have not tried that yet. If this is a bug, can't we have it as a feaure instead?
Can this capabliity be added to future release? And still be able to be called in SRT.
PLEASE? and Thank You.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Captive wrote:Also I tried doing the same, using a button instead of a label. It uses the first custom text, but not the second.
So it changes the "DefVal" to "Hi", and shows it - great. Try and then change it to something else after that.[...]support wrote:Here is a simple example which uses a dialog and subroutines and lets you change the default value of text with a variable declared AFTER the dialog is created:
Gosub>Test
Gosub>Test2
[...]
SRT>Test2
Let>DefVal=Hello
Show>Send,res
if>res=1,sendmail
End>Test2
[...]It still remains as "Hi".
This might also explain why putting the Let> above the Dialog> changes it once, but then it fails to change in future Let/Show combos.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
On my last example that showed variables and labels being changed with variables, all of those happened before the Dialog was "defined". If I change to last Goto>End to go back to the top and input error codes again, I get the message that the Dialog object has already been defined.
Now I am getting a better understanding of "defining" the Dialog.
But this would work really well if we had a new command like DialogClear>DialogName,variable1, variable2, variablen....... that would allow us to clear and then redefine those specific variables. This could be listed after the Show command like this:
Just a suggestion the power of this tool would be unlimited.
Now I am getting a better understanding of "defining" the Dialog.
But this would work really well if we had a new command like DialogClear>DialogName,variable1, variable2, variablen....... that would allow us to clear and then redefine those specific variables. This could be listed after the Show command like this:
I am thinking that this might not be a really big programming problem to implement. These are probably treated like properties of the Dialog object. Before definition of Dialog, the property variables are already blank. So the DialogClear> command would reset only the listed properties back to the same value they normally have before definition. Reset the flag to allow Dialog definition again, and then we could have repeated calls and use the variables. (Someone else's programming is always no big thing to do, huh?)Label>Top
Input>Code,Enter the error number: ( 1 / 2 / 3 )
Let>Step=Step%Code%
Goto>%Step%
Label>Step1
Let>WarningHelp=This is your FIRST WARNING!
Let>ErrorCaption= WARNING NOTICE!
Let>Sound=c:\windows\media\chimes.wav
Goto>Error
Label>Step2
Let>WarningHelp=Can't you stop making mistakes?
Let>ErrorCaption=YOU ARE A LOSER
Let>Sound=c:\windows\media\chord.wav
Goto>Error
Label>Step3
Let>WarningHelp=Uh Oh! You are about to be Fired!
Let>ErrorCaption=THIS IS 30 DAYS NOTICE!
Let>Sound=c:\windows\media\notify.wav
Goto>Error
.....
.....
Label>Error
Dialog>WarningWindow
Caption=%ErrorCaption%
Top=144
Width=250
Left=312
Height=150
Label=%WarningHelp%,34,30
Button=OK,28,80,75,25,1
Button=Cancel,120,80,75,25,2
EndDialog>WarningWindow
PlayWav>%Sound%
Show>WarningWindow,result
DialogClear>WarningWindow,%ErrorCaption%,%WarningHelp%
Goto>Top
Just a suggestion the power of this tool would be unlimited.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Hi,
Bob - your signature declares that you are called Robert - hence why I used that name - either change your sig or your name
You should be able to use variables in all objects - but just not the caption at the moment and the variable should be changeable afterwards.
You CAN declare dialogs anywhere you like, but clearly they must be declared before the Show statement is issued. They don't have to be at the top - in the middle is fine. They can be anywhere you like and you can have any number of different dialog declarations. But you can only Show a dialog after it has been created.
I am struggling to keep my head above water here and keep up with you to make a note of everything you guys want changed, don't like etc. We are a little disappointed that none of these observations were given in the last week or so of beta testing but emerged after release. Hay ho ... what's new.
Never-the-less, the custom dialogs are a very new feature, were extremely complicated to implement, but I am sure will improve organically over time as has Macro Scheduler in every other respect. Please keep posting suggestions for improvements and they will be taken on board and no doubt you will see future versions exhibit these improvements.
Thanks for all your valuable contributions.
Bob - your signature declares that you are called Robert - hence why I used that name - either change your sig or your name
You should be able to use variables in all objects - but just not the caption at the moment and the variable should be changeable afterwards.
You CAN declare dialogs anywhere you like, but clearly they must be declared before the Show statement is issued. They don't have to be at the top - in the middle is fine. They can be anywhere you like and you can have any number of different dialog declarations. But you can only Show a dialog after it has been created.
I am struggling to keep my head above water here and keep up with you to make a note of everything you guys want changed, don't like etc. We are a little disappointed that none of these observations were given in the last week or so of beta testing but emerged after release. Hay ho ... what's new.
Never-the-less, the custom dialogs are a very new feature, were extremely complicated to implement, but I am sure will improve organically over time as has Macro Scheduler in every other respect. Please keep posting suggestions for improvements and they will be taken on board and no doubt you will see future versions exhibit these improvements.
Thanks for all your valuable contributions.
MJT Net Support
[email protected]
[email protected]
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
(Signatures are too formal, log in name is Bob. Don't even get upset if you pronounce it backwards).
Didn't discover these issues earlier because the ShutDownWindows issue is a more important problem. See other posts on that.
Thanks for listening on the Dialog issues. And now I have been forced into a better understanding, so I can get more out of it until the next generation of improvements. Again, this is a great feature. No complaints, just clarifications and suggestions. Keep up the great work!
Didn't discover these issues earlier because the ShutDownWindows issue is a more important problem. See other posts on that.
Thanks for listening on the Dialog issues. And now I have been forced into a better understanding, so I can get more out of it until the next generation of improvements. Again, this is a great feature. No complaints, just clarifications and suggestions. Keep up the great work!
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!