Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!newsfe23.iad.POSTED!7564ea0f!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Organization: Canada Eat The Cookie Foundation
User-Agent: Thunderbird 2.0.0.19 (Windows/20081209)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to stop execution
References: <gp98u4$g9h$1@fred.mathworks.com>
In-Reply-To: <gp98u4$g9h$1@fred.mathworks.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Lines: 12
Message-ID: <XgWtl.34251$l71.6225@newsfe23.iad>
NNTP-Posting-Host: 24.79.146.116
X-Complaints-To: internet.abuse@sjrb.ca
X-Trace: newsfe23.iad 1236807863 24.79.146.116 (Wed, 11 Mar 2009 21:44:23 UTC)
NNTP-Posting-Date: Wed, 11 Mar 2009 21:44:23 UTC
Date: Wed, 11 Mar 2009 16:44:29 -0500
Xref: news.mathworks.com comp.soft-sys.matlab:524167


Todd Welti wrote:
> This might seem like a dumb question, but how do you stop code execution?  I dont mean
> 'return', or 'dbstop', or 'error'.  I just want to stop the code immediately, with no
> fanfare and just return to the command line.

There isn't a way: all of those routines have to be unwound and their workspaces
cleaned up, which might invoke exit handlers, and so on.

The closest I can think of is to have your main routine have a try/catch
and then when you wish to abort, error() the particular string that the
catch is keyed for, and when you detect it, bail out cleanly from your
main routine.