Dialog Box script

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
melb.robmac
Newbie
Posts: 12
Joined: Tue Jun 17, 2008 12:12 am
Location: Melbourne Australia
Contact:

Dialog Box script

Post by melb.robmac » Tue Oct 21, 2008 2:12 am

I am trying to write a script that I can use to run a "selection" of scripts by either checking a checkbox or using radio buttons.
I can setup the dialog box so that it looks the way I want it to look, however I am having some difficulty in working out how to detect if a checkbox is set to true or false (default is false).
I would like to avoid SRT> and other similar calls if possible too.
Thanks.
Rob
Melbourne, Australia

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

Post by JRL » Tue Oct 21, 2008 5:05 am

Here's a couple of samples that detect the state of checkboxes and change dialog labels to reflect the state. The first sample makes the change when the Ok button is pressed, the second sample makes the change immediately after a checkbox is altered. Both of these samples are using non-modal dialogs. The first sample could be written to work as a modal dialog, the second sample requires the dialog be non-modal. To see what's happening, step through these by pressing F8 in the editor and follow the results of each step in the watchlist.
I would like to avoid SRT> and other similar calls if possible too.
These samples use a subroutine for clarity. It makes the code easier to read and understand. However when writing code in which the user makes decisions such as checking a checkbox, the code will undoubtedly need to branch based on one user selection versus another user selection. There are two primary methods of branching, subroutines and labels. What is your reason for wanting to avoid "SRT> and other similar calls"?

Hope this is understandable and helpful.
Dick

Process on button pick

Code: Select all

Dialog>Dialog1
   Caption=Check box test
   Width=274
   Height=123
   Top=CENTER
   Left=CENTER
   Button=Ok,97,52,75,25,3
   CheckBox=msCheckBox1,msCheckBox1,13,8,97,False
   CheckBox=msCheckBox2,msCheckBox2,14,26,97,False
   Label=Checkbox 1 unchecked,128,8
   Label=Checkbox 2 unchecked,128,24
EndDialog>Dialog1

Show>dialog1

Label>Loop
  GetDialogAction>dialog1,res1
  If>res1=2,EOF
  If>res1=3,Process
  Wait>0.01
Goto>Loop

SRT>Process
  If>dialog1.mscheckbox1=True
    Let>dialog1.mslabel1=Checkbox 1 checked
  Else
    Let>dialog1.mslabel1=Checkbox 1 unchecked
  EndIf
  If>dialog1.mscheckbox2=True
    Let>dialog1.mslabel2=Checkbox 2 checked
  Else
    Let>dialog1.mslabel2=Checkbox 2 unchecked
  EndIf
  ResetDialogAction>Dialog1
END>Process

Label>EOF
Process on checkbox selection

Code: Select all

Dialog>Dialog1
   Caption=Check box test
   Width=274
   Height=123
   Top=CENTER
   Left=CENTER
   CheckBox=msCheckBox1,msCheckBox1,13,8,97,False
   CheckBox=msCheckBox2,msCheckBox2,14,26,97,False
   Label=Checkbox 1 unchecked,128,8
   Label=Checkbox 2 unchecked,128,24
EndDialog>Dialog1

Show>dialog1

Label>Loop
  GetDialogAction>dialog1,res1
  If>res1=2,EOF
  GoSub>Process
  Wait>0.01
Goto>Loop

SRT>Process
  If>dialog1.mscheckbox1=True
    Let>dialog1.mslabel1=Checkbox 1 checked
  Else
    Let>dialog1.mslabel1=Checkbox 1 unchecked
  EndIf
  If>dialog1.mscheckbox2=True
    Let>dialog1.mslabel2=Checkbox 2 checked
  Else
    Let>dialog1.mslabel2=Checkbox 2 unchecked
  EndIf
  ResetDialogAction>Dialog1
END>Process

Label>EOF

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