Changing Dialog Labels Programmatically Thx JRL & Marcus

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Changing Dialog Labels Programmatically Thx JRL & Marcus

Post by jpuziano » Fri Feb 17, 2006 12:59 am

Hi Support and All,

I have a dialog that shows a progressbar. I want to also display the number of seconds remaining so I'm using an Edit field and updating the value in a loop, here's the code showing just the edit field.


Dialog>MyDialog
Caption=can the blinking cursor be suppressed?
Width=239
Height=81
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=0
Resize=0
Label=Countdown,8,24
Label=seconds left,126,24
Edit=msEdit1,75,19,38,
EndDialog>MyDialog

Show>MyDialog

Let>k=10

Repeat>k
Let>MyDialog.msEdit1=k
Sub>k,1
ResetDialogAction>MyDialog
Wait>1
Until>k,0

Label>End


Since this is an Edit field, it also shows a blinking cursor where a user might type, but I'm only using it for display purposes. Can the blinking cursor be turned off? Could a property be added?

user editable: Y/N
Y - it would be just like today
N - there would be no cursor, users couldn't type in the field, only changeable programmatically (perhaps the field is grey instead of white)

Or, if we could update the value of dialog labels programmatically, I'd use that instead. Is that on the wish list? Could it be?

That would make dialogs more dynamic as label text could be changed programmatically to provide feedback, progress, etc. Or even the Caption text of a dialog could be used to provide feedback, if it were changeable.

Just a thought. Maybe you have another way or someone else out there?

Thanks

P.S. Kudos to JRL for the technique in the following post, ingenious.

Dialog and large selection
http://www.mjtnet.com/forum/viewtopic.php?t=2597
Last edited by jpuziano on Sat Feb 18, 2006 9:06 pm, edited 5 times in total.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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

Post by JRL » Fri Feb 17, 2006 5:20 am

jpuziano,
Thanks for the compliment.

As for your post, you could use a button.


Let>msEdit1=10
Dialog>MyDialog
Caption=can the blinking cursor be suppressed?
Width=239
Height=81
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=0
Resize=0
Label=Countdown,8,24
Label=seconds left,126,24
Button=%msEdit1%,72,16,49,25,0
EndDialog>MyDialog


Show>MyDialog

Let>k=10

Repeat>k
Let>MyDialog.msEdit1=k
Sub>k,1
Let>MyDialog.MSBUTTON2=%k%
ResetDialogAction>MyDialog
Wait>1
Until>k,0

Label>End


Hope this helps,
Dick
Last edited by JRL on Fri Feb 17, 2006 1:38 pm, edited 1 time in total.

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Feb 17, 2006 7:58 am

Thanks JRL, it does help... but about the following line:

Let>MyDialog.MSBUTTON2=%k%

MSBUTTON2 is not defined in the dialog... where does it come from?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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

Post by JRL » Fri Feb 17, 2006 1:37 pm

MSBUTTON2 is not defined in the dialog... where does it come from?
It is one of those nice tidbits provided by the fine folks at MJTnet. I can't explain "where it comes from" any more than I can explain why "Dialog>MyDialog" creates a dialog box. You'd have to ask Marcus. However, I can tell you where I found it. If you step through the script in the MS editor line by line using the F8 key. And if you have gone to the Debug menu item and turned on the Watch List, you will see variables associated with the dialog acquiring definitions. In the previously posted script one of those was MyDialog.MSBUTTON2.

I just reread your post and the following sample does the same thing using a label. Step though with the editor and watch the magic happen on the right side of the editor.



Let>msEdit1=10
Dialog>MyDialog
Caption=can the blinking cursor be suppressed?
Width=239
Height=81
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=0
Resize=0
Label=Countdown,8,24
Label=seconds left,126,24
Label=msEdit1,88,24
EndDialog>MyDialog

Show>MyDialog

Let>k=10

Repeat>k
Let>MyDialog.msEdit1=k
Sub>k,1
Let>MyDialog.MSLABEL2=%k%
ResetDialogAction>MyDialog
Wait>1
Until>k,0

Label>End



Hope this is helpful,
Dick

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Feb 17, 2006 4:37 pm

JRL supplies the magic... again! Yes, that's exactly the effect I was looking for... thank you very much. :D

The original Subject Title of this post was Can blinking cursor be suppressed in a dialog edit field? but I changed it so that more people will be able to find this post and see the technique you've explained.

In my opinion, this makes dialogs much more powerful... and it was already there... good find indeed.

Support, this technique seems to be undocumented... but since it looks to be so useful, would you consider documenting it in the help file on dialogs? I think an example added there showing how to dynamically change Label text would be the fastest way to acquaint your users with this powerful ability of Macro Scheduler dialogs.

Thanks again JRL!!!
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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

Post by JRL » Fri Feb 17, 2006 10:34 pm

It took me a while searching the forums but I finally found the post that taught me this little trick.

The thanks should go to Marcus.

http://www.mjtnet.com/forum/viewtopic.p ... t=mydialog

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Sat Feb 18, 2006 9:01 pm

Hi JRL,

Ahh, I see now that this undocumented feature is "documented" in the Scripts and Tips forum... thanks for that Marcus.

However, I'm still wondering why something so useful isn't officially documented? Could an example be added to the help file under dialogs that shows how to dynamically change label text? The help file is always the first place I go to and had it been there... I would have been using this much earlier. Just a suggestion, but I'm thinking it would help others as well.

Thanks again JRL for answering my original post and of course to Marcus for the high level of support provided through these forums...
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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