Subroutine Exit

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

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

Subroutine Exit

Post by armsys » Sun Jan 05, 2003 1:05 am

Is it possible to exit from a subroutine without reaching the end?


SRT>Subroutine
....
If>Decion1=True,Exit Decision2=True,Continue
Goto>End Continue
....
End>Subroutine


Thanks for your enlightenment.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Sun Jan 05, 2003 7:55 pm

Hi,

That would work but it would cause script execution to continue from the new label and it won't get back to the end of the subroutine and hence the code after the subroutine call.

What you need to do is:

SRT>SubA

If>Decision1=true,ExitSubA

Label>ExitSubA
End>SubA

By setting up an exit label at the end of each subroutine you have a way to jump to the end of it allowing script execution to continue properly - i.e. the end of the subroutine is reached and the statement after the calling statement is processed as normal.
MJT Net Support
[email protected]

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

Post by armsys » Mon Jan 06, 2003 1:45 am

Hi Support,

Thanks a lot for revealing an amazinlgy simple solution. I am still heavily influenced by the structural languages such as Clipper. Thanks to your enlightenment, my coding in future will be more flexible in line with the Goto idiosyncrasy.

Thanks again.

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