Function Repository Resource:

# LimitedMessage

Issue a message a customized number of times per evaluation

Contributed by: Bob Sandheinrich
 ResourceFunction["LimitedMessage"][n,symbol::tag,e1,e2,…] issues Message[symbol::tag,ei,e2,…] up to n times per evaluation. ResourceFunction["LimitedMessage"][{n,"NoStopMessage"},symbol::tag,e1,e2,…] issues the message up to n times per evaluation and stops without a General::stop message.

## Details

By default, Message issues a given message three times per evaluation before stopping with a General::stop message. ResourceFunction["LimitedMessage"] allows you to set the number of times to a value different than three.
ResourceFunction["LimitedMessage"][{n,False},] is a convenient alternative to ResourceFunction["LimitedMessage"][{n,"NoStopMessage"},] for those of us that can never remember magic string values.

## Examples

### Basic Examples (1)

Run an evaluation that issues a message five times, but limit it to only issue twice:

 In[1]:=

### Scope (3)

Define a function with a message that can be issued up to ten times per input evaluation:

 In[2]:=

Use the function on data that frequently generates a message:

 In[3]:=
 Out[3]=

Prevent a message from being issued at all by limiting the count to zero:

 In[4]:=

Turn off the General::stop message:

 In[5]:=

Alternatively use True or False to control the stop message:

 In[6]:=
 In[7]:=

### Properties and Relations (2)

By default, Message issues messages three times:

 In[8]:=

LimitedMessage[3,] is equivalent:

 In[9]:=

Use Off to allow all messages:

 In[10]:=
 In[11]:=
 In[12]:=

LimitedMessage[Infinity,] is equivalent:

 In[13]:=

Bob

## Version History

• 1.0.0 – 19 April 2022

## Author Notes

The "NoStopMessage" syntax to prevent the stop message is a pretty ugly design. It would be nice to implement it as an option, but Message is variable length and accepts any expression, including Rule as an argument, so there would be an ambiguity about whether the rule here is an option or a message template value:

 In[1]:=