How 2 question: Exit Macro when a step fails and log error?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
AntoniusMomac
Junior Coder
Posts: 20
Joined: Fri Dec 07, 2007 7:46 am
Location: New York City, NY

How 2 question: Exit Macro when a step fails and log error?

Post by AntoniusMomac » Mon Jan 14, 2008 8:55 pm

I'm not clear about what you need to do in order to exit a macro when any one step fails and log the error.

Do you need an If: then: for each step.

For instance, if I had the following script:

Code: Select all

Let>STEP_DELAY=200

Let>RP_WAIT=10
Let>RP_DISPLAYERROR=1
Run Program>C:\Program Files\INSSINC Software\Futrak\issFutrak.exe
IfWindowOpen>Data Synchronization,AcceptUpDates,SetSysDate
Label>AcceptUpDates
SetFocus>Data Synchronization
Send>y
Label>SetSysDate
WaitWindowOpen>Futrak System Date
SetFocus>Futrak System Date
Wait>0.24
Press Tab
Wait>0.24
Send>02/28/2005
Wait>0.24
Press Tab
Wait>0.24
Press Enter
WaitWindowOpen>Futrak - The Hedge Management System
WindowAction>1,Futrak - The Hedge Management System
Do I need to "try" each step and the look for an error? Such as no window or a new window popping up?

-OR- is there a q better way to verify if any one step failed, stop the macro and log an error, or send the error log via e-mail?

I'm clueless when it comes to anticipating errors and handling them
Love Simple!! "Simplicity means the achievement of maximum effect with minimum means" - Dr. Koichi Kawana, Architect, designed the botanical gardens

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

Post by Marcus Tettmar » Tue Jan 22, 2008 12:23 pm

It depends what you mean by errors. You'd need to code the checks yourself. E.g. if you're expecting a window to be open you can check if it is open and if not, log the error, or do something different, or exit, or do whatever you want:

Code: Select all

IfWindowOpen>my_window
  ..ok
Else
  Exit>1
Endif
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
AntoniusMomac
Junior Coder
Posts: 20
Joined: Fri Dec 07, 2007 7:46 am
Location: New York City, NY

Post by AntoniusMomac » Tue Jan 22, 2008 2:04 pm

Follow up on the use of "exit>"

if you are calling a script that calls a script, which calls another script that fails with an exit command. will the entire process stop?

Here's the an example. the main script just controls the follow of the called scripts:

--Main.scp
Macro>Test_1.scp
--Test_1.scp
Macro>Test_1.1
If windowexist
message>Good
Else
Exit
Endif

Will the Main Script stop on exit?
Love Simple!! "Simplicity means the achievement of maximum effect with minimum means" - Dr. Koichi Kawana, Architect, designed the botanical gardens

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

Post by Marcus Tettmar » Tue Jan 22, 2008 4:59 pm

Exit will break from the current macro. So if you call a macro and exit from that you exit only that macro and the calling script will continue.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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