Is there a way to abort a script, within the script itself ?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
lebrocoli
Pro Scripter
Posts: 53
Joined: Tue Sep 06, 2005 9:28 pm

Is there a way to abort a script, within the script itself ?

Post by lebrocoli » Mon Oct 15, 2007 6:32 pm

Hi, me again!

I am trying to make the scritp to exit on error. What is the best way to do that from inside the script ?

I tried to send CTRL-B or SHIFT-ESC but my test app does not respond to thoses.


I am trying to do something like:

If>{%WW_RESULT%="FALSE"}
Exit
Else
MessageModal>All is good. Continue.
EndIf

OR

If>{%WW_RESULT%="FALSE"}
Goto>EndLabel
Else
MessageModal>All is good. Continue.
EndIf

Label>EndLabel
bla bla


The problem for the 2nd case is that if all is good, the script will also execute the 'Label' code just because it is following the EndIf.

What is the best/easiest way to exit internally ?

Thanks!

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Oct 15, 2007 6:42 pm

So why not:

If>{%WW_RESULT%="FALSE"}
Goto>EndLabel
Else
MessageModal>All is good. Continue.
EndIf


Goto>EndScript
Label>EndLabel
bla bla


//very end of script
Label>EndScript
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Mon Oct 15, 2007 6:44 pm

keep it simple whenever possible. No need for the brackets {} in this case.

If>WW_RESULT=False
goto>EndProgram
else
goto>WhatIsNext
endif

label>WhatIsNext
.....

label>EndProgram
mdl>All done


Also, if you want to break execution of the program you might try adding an On_Event for a specific keystroke combination.

lebrocoli
Pro Scripter
Posts: 53
Joined: Tue Sep 06, 2005 9:28 pm

Post by lebrocoli » Mon Oct 15, 2007 7:11 pm

Ok. Seems to work great!

Thank!

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