MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Message[] color

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8959] Re: Message[] color
  • From: "P.J. Hinton" <paulh>
  • Date: Mon, 6 Oct 1997 01:59:27 -0400
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at wolfram.com

Marlies Brinksma wrote:

> Sometimes I use the function Message[] for error messages, and sometimes
> for warning messages. It would be nice if I could set the color of warning messages to (for example) blue, and the error messages to red.
> 
> I don't think it is possible because the color is a setting of the notebook,
> in which the expressions are evaluated. But maybe I'm wrong? (hopefully!)
> Can someone think of a way to get the desired result?
> 
> Thanks in advance for any help!

Text generated by the Message[ ] function is displayed using the
Message cell style.  This color of this text is governed by the Style 
Sheet you are using.  While editing the style sheet will allow you 
to change the color of all message texts, there is no straightforward
mechanism for making warning messages appear in blue and error 
messages appear in red.  The kernel and the front end do no see any
distinction between what you consider a "warning" and what you 
consider an error.  

Mathematica's typesetting machinery does allow for the embedding of 
StyleBoxes (which can alter the color of the text, but not the
message label; i.e. Message::tag), but you would need to do this
modification for each message text in Messages.m.  This would be
an admittedly tedious task indeed!  If you are wanting to modify 
your own set of warning messages, then this might not be such a
problem.

Here is an example of how you might go about doing this:

symbolname::error = 
  "\!\(\*StyleBox[\"This is an error message\",FontColor -> \
RGBColor[1,0,0]]\)"

Message[symbolname::error]

Hope this helps!

--
P.J. Hinton	
Mathematica Programming Group           paulh at wolfram.com
Wolfram Research, Inc.                  http://www.wolfram.com/~paulh/


  • Prev by Date: Re: Re: How assume symbol integer?
  • Next by Date: Re: Sequence is funny !
  • Previous by thread: Message[] color
  • Next by thread: Deleting Graphics Elements