Thread Subject: Aborting a function politely

Subject: Aborting a function politely

From: Claudio Pedrazzi

Date: 25 Nov, 2009 10:56:01

Message: 1 of 2

Hi everybody,
I know the "error" call that can abort a function call and jump back to the prompt level. This function writes on the command window a "red message" that some users could consider "ugly" and not particularly user friendly.

Is there some way to jump to prompt level, aborting all levels of nested function calls, writing out something in "normal" format, or maybe writing nothing at all (I could always use a msgbox call to explain the abrupt stop).

I need this for the case of fatal errors (missing files, completely wrong user input, and so on).

Thanks a lot & best regards
Claudio

Subject: Aborting a function politely

From: Jan Simon

Date: 25 Nov, 2009 11:45:18

Message: 2 of 2

Dear Claudio!

> I know the "error" call that can abort a function call and jump back to the prompt level. This function writes on the command window a "red message" that some users could consider "ugly" and not particularly user friendly.
>
> Is there some way to jump to prompt level, aborting all levels of nested function calls, writing out something in "normal" format, or maybe writing nothing at all (I could always use a msgbox call to explain the abrupt stop).
>
> I need this for the case of fatal errors (missing files, completely wrong user input, and so on).

There have been some posts here concerning returning from deeply nested functions. But in your case of fatal errors, I think and warning in red color is absolutely appropriate.

You can suppress the display of warnings by encapsulating the calls in a TRY-CATCH-END block. The in the CATCH you can dispaly the error message in black (as usual) and return to the prompt eith RETURN.

Good luck, Jan

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
abort terminate... Claudio Pedrazzi 25 Nov, 2009 05:59:05
rssFeed for this Thread

Contact us at files@mathworks.com