Re:Full text of the current warning message(s)
- To: mathgroup at smc.vnet.net
- Subject: [mg33410] Re:Full text of the current warning message(s)
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Wed, 20 Mar 2002 01:53:21 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Vladimir Bondarenko wanted to see the full text of messages from a specific In[] line. I get the job done with the following code which makes transparent changes to 'Message' and defines a new function 'MyMessageList'. MyMessageList[_Integer]:=Hold[]; $ModifyMessage=True; Unprotect[Message]; Message[args__]/;$ModifyMessage:= Block[{$ModifyMessage}, If[MyMessageList[$Line]===Hold[], MyMessageList[$Line]=Hold[Message[args];], (* else *) MyMessageList[$Line]= Insert[MyMessageList[$Line],Unevaluated[Message[args]],{1,-2}] ]; Message[args] ]; Protect[Message]; (*------- Now you can evaluate the following which causes messages. --------*) In[5]:= {6>I, Prime[3.4]} Greater::nord: Invalid comparison with I attempted. Prime::intpp: Positive integer argument expected in Prime[3.4]. Out[5]= {6>I,Prime[3.4]} (* Then sometime later you might want to see what messages resulted from In[5] and the following works. *) In[22]:= messgs=MyMessageList[5] Out[22]= Hold[Message[Greater::nord,I]; Message[Prime::intpp,Prime[3.4]]; ] (* You need to use ReleaseHold if you want to see the text of the messages. *) In[23]:= ReleaseHold[messgs] Greater::nord: Invalid comparison with I attempted. Prime::intpp: Positive integer argument expected in Prime[3.4]. (* If In[n] made no messages, MyMessageList[n] returns Hold[]. *) ------------------------- Get Mathematica Tips, Tricks from http://www.verbeia.com/mathematica/tips/Tricks.html Regards, Ted Ersek