This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Input and Output / Messages  /

  • Message[ symbol :: tag ] prints the message symbol :: tag unless it has been switched off.
  • Message[ symbol :: tag , , , ... ] prints a message, inserting the values of the as needed.
  • Message generates output on the channel $Messages.
  • You can switch off a message using Off[ symbol :: tag ]. You can switch on a message using On[ symbol :: tag ].
  • Between any two successive input lines, Mathematica prints a message with a particular name at most three times. On the last occurrence, it prints the message General::stop.
  • During the evaluation of a particular input line, names of messages associated with that input line are appended to the list $MessageList, wrapped with HoldForm. At the end of the evaluation of the n input line, the value of $MessageList is assigned to MessageList[ n ].
  • Message[ mname , , , ... ] is printed as StringForm[ mess , , , ... ] where mess is the value of the message mname. Entries of the form ` i ` in the string mess are replaced by the corresponding .
  • Given a message specified as symbol :: tag, Message first searches for messages symbol :: tag :: for each of the languages in the list $Language. If it finds none of these, it then searches for the actual message symbol :: tag. If it does not find this, it then performs the same search procedure for General:: tag. If it still finds no message, it applies any value given for the global variable $NewMessage to symbol and " tag ".
  • If you specify a message as symbol :: tag :: lang, then Message will search only for messages with the particular language lang.
  • See the Mathematica book: Section 2.8.21.
  • See also: Print, CellPrint, Write, On, Off, Check, MessageList.

    Further Examples

    You can mimic all aspects of the way in which built-in Mathematica functions generate messages with Message. You can for example switch on and off messages using On and Off and Message will automatically look for General:: tag if it does not find the specific message s :: tag
    This defines the text of a message associated with f.



    Here is the function f.


    When the argument of f is greater than 10, the message is generated.


    f::overflow: Factorial argument 20 too large.


    This switches off the message.


    Now the message is no longer generated.