Termination Subroutine.

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
psiquetp
Junior Coder
Posts: 25
Joined: Tue Jul 17, 2018 7:56 pm

Termination Subroutine.

Post by psiquetp » Thu Jul 19, 2018 5:17 pm

I want my code to report abnormal termination; that is, to run a routine that in case of an error it might report them, close resources, send an email, or whatever.

So that means that after the subroutine the program should end... I tried to create the routine and goto a label at the end of the macro but the scheduler is sending an error message about branching out from subs... is there any other way to terminate the execution than to reach the end? can the error message be muted?

Code: Select all

//Subroutine to report an error -----------------------------
//Input: ERROR_MESSAGE .- String to be displayed as the error.
SRT>ReportError
    MessageModal>%ERROR_MESSAGE%
    Goto>EndOfMacro
END>ReportError
....
Label>EndOfMacro
Thank you!
Carlos Alberto

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

Re: Termination Subroutine.

Post by Marcus Tettmar » Thu Jul 19, 2018 5:59 pm

Just put an Exit statement in your subroutine:

Code: Select all

SRT>ReportError
    MessageModal>%ERROR_MESSAGE%
    Exit>0
END>ReportError
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