Creating a Cancel Button in a Dialog

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Dman
Junior Coder
Posts: 26
Joined: Mon Apr 21, 2008 2:46 am
Location: Melbourne, Australia

Creating a Cancel Button in a Dialog

Post by Dman » Thu Jun 05, 2008 11:01 pm

I've tried a few combinations to try to trigger "End" on clicking the cancel button on a dialog, but the macro still keeps running after the button is pressed, with the macroscheduler systray icon flashing etc..

Can someone please tell me what I've done wrong here?

Code: Select all

Dialog>dlgPINREQ
   Caption=PIN Request Details
   Width=356
   Height=300
   Top=150
   Left=800
   Max=0
   Min=0
   Close=1
   Resize=0
   Label=First Name,16,8,true
   Label=Last Name,16,56,true
   Label=PIN,16,104,true
   Label=Date XX/XX/XX,16,152,true
   Label=Start Time XX:XX,16,200,true
   Label=Finish Time XX:XX,128,200,true
   Edit=FirstName,16,24,217,
   Edit=LastName,16,72,217,
   Edit=PIN,16,120,217,
   Edit=Date,16,168,217,
   Edit=Start,16,216,97,
   Edit=Finish,128,216,105,
   Button=Run,256,216,73,25,1
   Button=Cancel,256,168,73,25,2
EndDialog>dlgPINREQ

Show>dlgPINREQ,r
If>r=1
  Let>pinreqfirst=dlgPINREQ.FirstName
  Let>pinreqlast=dlgPINREQ.LastName
  Let>pinreqpin=dlgPINREQ.PIN
  Let>pinreqdate=dlgPINREQ.Date
  Let>pinreqstart=dlgPINREQ.Start
  Let>pinreqfinish=dlgPINREQ.Finish
If>r=2,End
Endif

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu Jun 05, 2008 11:43 pm

Try:

Dialog>dlgPINREQ
Caption=PIN Request Details
Width=356
Height=300
Top=150
Left=800
Max=0
Min=0
Close=1
Resize=0
Label=First Name,16,8,true
Label=Last Name,16,56,true
Label=PIN,16,104,true
Label=Date XX/XX/XX,16,152,true
Label=Start Time XX:XX,16,200,true
Label=Finish Time XX:XX,128,200,true
Edit=FirstName,16,24,217,
Edit=LastName,16,72,217,
Edit=PIN,16,120,217,
Edit=Date,16,168,217,
Edit=Start,16,216,97,
Edit=Finish,128,216,105,
Button=Run,256,216,73,25,1
Button=Cancel,256,168,73,25,0
EndDialog>dlgPINREQ


Show>dlgPINREQ,r
If>r=1
Let>pinreqfirst=dlgPINREQ.FirstName
Let>pinreqlast=dlgPINREQ.LastName
Let>pinreqpin=dlgPINREQ.PIN
Let>pinreqdate=dlgPINREQ.Date
Let>pinreqstart=dlgPINREQ.Start
Let>pinreqfinish=dlgPINREQ.Finish
Endif
If>r1,End

Dman
Junior Coder
Posts: 26
Joined: Mon Apr 21, 2008 2:46 am
Location: Melbourne, Australia

Post by Dman » Fri Jun 06, 2008 12:17 am

Thanks

I had to put Label>End at the end of the macro though..

!

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Fri Jun 06, 2008 12:28 am

Hi Dman,
Please re-read my last re-edited post.
The Cancel button in your original script was never executed because it's located inside an IF...ENDIF construct.

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