Using a dialog text field to output messages

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
imperium
Newbie
Posts: 2
Joined: Sun Mar 02, 2008 7:54 pm

Using a dialog text field to output messages

Post by imperium » Sun Mar 02, 2008 7:57 pm

Hi,

How can I have variables sent to a text field in a dialog rarther than the standerd pop up message used by MS?

This is so I can give the user feed back through the dialog ive made.

Cheers.

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

Post by JRL » Mon Mar 03, 2008 2:38 am

Here is a sample dialog with a message in a variable being displayed four different ways. As a label, in an edit box, in a button and in a memo box. The edit box and memo box will require a ResetDialogAction to force the display of the reset dialog1.msedit1 and dialog1.msmemo1 variables. The label and button only require a GetDialogAction though they will also reset with a ResetDialogAction.

Usually I simply use a label. Buttons are nice because they display a nice border and the text will automatically center itself within the button borders. One problem with an edit or memo box is that they are editable. One nice thing about a memo box is that text will automatically wrap. To wrap text in a label or button you must explicitly place a carriage return and line feed %CRLF% in the line in the position where the line should wrap.

Hope this is helpful.

Code: Select all

Dialog>Dialog1
   Caption=Dialog Message
   Width=445
   Height=303
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Label= ,24,16
   Edit=msEdit1,24,40,393,
   Button= ,24,80,393,41,3
   Memo=msMemo1,24,136,105,89,
EndDialog>Dialog1

Show>dialog1

Let>Message=Select the "X" to close this window
Let>dialog1.mslabel1=%Message%
Let>dialog1.msedit1=%Message%
Let>dialog1.msbutton1=%Message%
Let>dialog1.msmemo1=%Message%
ResetDialogAction>dialog1

Label>Loop
  GetDialogAction>dialog1,res1
  If>res1=2,EOF
Goto>Loop

Label>EOF


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

Post by jpuziano » Mon Mar 03, 2008 3:29 am

Great example and explanation JRL, thanks for posting this.

To show how things would look with a variable that grows over time, I added a few lines to demo this... adding in %CRLF% every 40 chars for the label and button.

Code: Select all

Dialog>Dialog1
   Caption=Dialog Message
   Width=445
   Height=303
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Label= ,24,16
   Edit=msEdit1,24,40,393,
   Button= ,24,80,393,41,3
   Memo=msMemo1,24,136,105,89,
EndDialog>Dialog1

Show>dialog1

Let>Message=Select the "X" to close this window
Let>dialog1.mslabel1=%Message%
Let>dialog1.msedit1=%Message%
Let>dialog1.msbutton1=%Message%
Let>dialog1.msmemo1=%Message%

Length>Message,char_length
Let>char_length_to_wrap_at=40

Label>Loop
ResetDialogAction>dialog1

//Label>Loop
  GetDialogAction>dialog1,res1
  If>res1=2,EOF

  ConCat>Message,.
  Let>char_length=char_length+1
  ConCat>dialog1.msedit1,.
  ConCat>dialog1.msmemo1,.
  If>char_length=char_length_to_wrap_at
    Let>char_length=0
    ConCat>dialog1.mslabel1,%CRLF%
    ConCat>dialog1.msbutton1,%CRLF%
  ELSE
    ConCat>dialog1.mslabel1,.
    ConCat>dialog1.msbutton1,.
  ENDIF

Wait>0.25

Goto>Loop

Label>EOF
If the variable to display is a growing string, the memo box with its auto-wrapping looks like a good choice.
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 - :-)

imperium
Newbie
Posts: 2
Joined: Sun Mar 02, 2008 7:54 pm

Post by imperium » Mon Mar 03, 2008 5:53 pm

thanks guys!

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