({{, symbol::tag
is a name for a message. }})

OpenersNotesSection(Spacer1)Details

You can specify messages by defining values for symbol::tag.

symbol::tag is converted to (RefLink[MessageName, paclet:ref/MessageName])[symbol,"tag"]. tag can contain any characters that can appear in symbol names. symbol::"tag" can also be used.

Assignments for s::tag are stored in the (RefLink[Messages, paclet:ref/Messages]) value of the symbol s.

The f::usage message is typically defined for functions intended for general use, giving a description of how to use the function.

?f prints out the message f::usage.

When ?form finds more than one function, only the names of the functions are printed.

You can switch on and off messages using (RefLink[On, paclet:ref/On])[s::tag] and (RefLink[Off, paclet:ref/Off])[s::tag].

(RefLink[MessageName, paclet:ref/MessageName])[symbol,"tag","lang"] or symbol::tag::lang represents a message in a particular language.

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Define a usage message for a function:

f::usage="f[x] gives (x - 1)(x + 1)";

Show the usage message:

?f

Process messages generated during an evaluation:

{Sin[1,2.],BesselJ[3,4.],Log[5,6.],Exp[7,8.]}

mess = MessageList[-1]

mest = Cases[mess,HoldForm[MessageName[f_,s_]]->{f,s}]

OpenersExampleSection1(Spacer1)Scope  (1)

Define a function that will test another function and give the argx message if needed:

oneargtest[f_, args___] := Module[{nargs = Length[{args}]},If[nargs≠ 1,Message[MessageName[f,"argx"],nargs,1];False,True]]

oneargtest[g, 1,2]

Define g to use the test and return unevaluated when it fails:

g[args___]  := Module[{x = First[{args}]},(x-1)(x+1)] /; oneargtest[g,args]

g[1,2]

g[1.5]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Message, paclet:ref/Message])  ▪  (RefLink[MessageList, paclet:ref/MessageList])  ▪  (RefLink[$MessageList, paclet:ref/$MessageList])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Messages, paclet:tutorial/Messages])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Messages, paclet:guide/Messages])}, {▪(RefLinkPlain[Package Development, paclet:guide/PackageDevelopment])}})}})