MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Limiting the number of messages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103937] Re: Limiting the number of messages
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Tue, 13 Oct 2009 07:20:30 -0400 (EDT)
  • References: <hahsi2$jm$1@smc.vnet.net>

Sean McConnell wrote:
> Hi, 
> 
> I'm creating a program with procedures that often depend on
> sub-procedures. Many times I allow the sub-procedures to do the input
> checking, so I don't have to write a the same error trapping conditions
> and messages for each level of the program. The problem is however that
> although the 'input checking' is passed on to a sub-procedure, the main
> procedure continues to attempt to evaluate, and can usually return a
> very long list of error messages whilst it foolishly attempting to
> evaluate with improperly input variables.
> 
> I would like to know how to make a procedure abort its evaluation after
> say 3 or so messages, and simply return the name of the procedure and
> the variables (as happens when you use /; for conditionals). I have
> tried the use of Check[], and although it checks for messages, it will
> only return what is typed in to the space for a second argument (eg:
> Check[f[a], "problem"] will return simply "problem"), I would like to be
> able to tell the user how they have screwed up.
> 
> Many thanks,
> 
> Sean McConnell.
> 
> 
Really, you need to be able to stop processing (after generating an 
error message or something) and come out to a much higher level of your 
program. The Throw and Catch functions should enable you to do this. If 
you simply need to stop executing altogether after issuing an error 
message, Abort[] is useful.

Note however that Abort[] will not stop the execution of subsequent 
cells if a whole notebook evaluation initiated the process.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Mathematica 7.01 and Mac OS 10.6 (Snow Leopard)
  • Next by Date: Re: Convert Graphics3D to Graphics2D. Is it possible?
  • Previous by thread: Re: Limiting the number of messages
  • Next by thread: Re: Re: Limiting the number of messages