I have written code such that if it runs into a particular function, a warning message is issued. However, it is common for the program to call this function several times in a single evaluation, but the warning message need be issued only once.
How do you limit the number of times a message is issued per evaluation?
Here is an example:
Clear[badness];
ClearAll[badness];
badness::oops = "Watch out! Result could be misinterpreted.";
badness[0] := CompoundExpression[Message[badness::oops]; 0]
Clear[reduction]
f[0] = 0;
reduction = {f[x_] :> x + f[x - 1] + badness[0]};
So, If the user runs the following:
f[5] //. reduction
we get:

Is there a way to limit the number of times (without also getting the General::stop) the message badness:oops is given to the user? (In the particular case for my code, I would like to limit it to just one time.)
CurrentValue[$FrontEndSession, {MessageOptions, "MaxMessageCount"}] = 1;orSetOptions[$FrontEndSession, {MessageOptions -> {"MaxMessageCount" -> 1}}]would the job , but it doesn't -- you still get 3 messages beforeGeneral::stopkicks in :( -- Version 9.0.1.0 Windows 8 64bit). – kglr Aug 24 '14 at 18:51