Is there any way to allow a message to appear more than three times before General::stop shuts it off?
I have some Mathematica code that analyzes data in a database and uses Message
to report when expected data is missing. By default, Mathematica will allow this message to appear only three times before it gets shut off, but I'd like this message to appear as often as the errors do.
The solutions I can think of are
Off[General::stop];
but this kills limits for all error messages, not just this one,
or just to switch to Print
, which seems inelegant.
Is there some way to allow this one message to appear more than three times, while leaving behavior unchanged for the rest?
Answer
You can do something like this:
resetMessages[symbol_] :=
With[{mysymbol = symbol},
Unprotect[$MessageList]; $MessageList =
DeleteCases[$MessageList, HoldForm[MessageName[mysymbol, _]]];
Protect[$MessageList];]
And you will have to call it after each function...
Sqrt[a, b, c, d]; Exp[a, b]; resetMessages[Exp]; Sqrt[a, b, c, d]; \
Exp[a, b]; resetMessages[Exp]; Sqrt[a, b, c, d]; Exp[a, b]; \
resetMessages[Exp]; Sqrt[a, b, c, d]; Exp[a, b]; resetMessages[Exp]; \
Sqrt[a, b, c, d]; Exp[a, b]; resetMessages[Exp]; Sqrt[a, b, c, d]; \
Exp[a, b]; resetMessages[Exp]; Sqrt[a, b, c, d]; Exp[a, b]; \
resetMessages[Exp];
Sqrt::argx: Sqrt called with 4 arguments; 1 argument is expected. >>
Exp::argx: Exp called with 2 arguments; 1 argument is expected. >>
Sqrt::argx: Sqrt called with 4 arguments; 1 argument is expected. >>
Exp::argx: Exp called with 2 arguments; 1 argument is expected. >>
Sqrt::argx: Sqrt called with 4 arguments; 1 argument is expected. >>
General::stop: Further output of Sqrt::argx will be suppressed during this calculation. >>
Exp::argx: Exp called with 2 arguments; 1 argument is expected. >>
Exp::argx: Exp called with 2 arguments; 1 argument is expected. >>
Exp::argx: Exp called with 2 arguments; 1 argument is expected. >>
Exp::argx: Exp called with 2 arguments; 1 argument is expected. >>
Exp::argx: Exp called with 2 arguments; 1 argument is expected. >>
Comments
Post a Comment