Search code examples
wolfram-mathematicamathematica-frontend

Formatting Message arguments


Can anyone explain why the first of these expressions works as expected while the second does not? What is the difference between "number one" and DisplayForm@"number one"?

Block[{$MessagePrePrint}, Message[f::event, DisplayForm@"number one"]]

Block[{$MessagePrePrint}, Message[f::event, "number one"]]

Solution

  • The error message is a clue:

    An unknown box name (Times) was sent as the BoxForm for the expression. Check the format rules for the expression.

    I presume $MessagePrePrint is low level, like $PreRead, and its output needs to be a valid box structure.