MathGroup Archive 2002

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

Search the Archive

Re:Full text of the current warning message(s)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33510] Re:Full text of the current warning message(s)
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Sun, 24 Mar 2002 01:44:07 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Vladimir Bondarenko  wanted to make it so he could see the full text of
messages from a specific  In[]  line.  
The other day I provided a solution that seemed to do the trick, but
Vladimir noted that it collects lots of spurious messages from evaluating
the following input.

   In[6]:=
    Integrate[ArcTan[1-Sqrt[1-z^(-1)]], {z,-1,1}]


I improved on my ealier solution. 
After evaluating the code below you can evaluate 
   FullMessageList[6]
and get the messages (unevaluated) that resulted from  In[6]  except the
(General::stop) message isn't included.  Curiously the (General::stop)
message is displayed if you use ReleaseHold on the messages returned by
FullMessageList.

(********* Note **********)
I was in the mood for writing robust code today, so I use 
 Apply[f1, expr1, Heads->False]   and   Map[f2, expr2, Heads->False]
instead of the shorter forms  (f1@@expr1) and (f2/@expr2) respectively. 
By using the longer forms my function definitions don't care what the option
is set to via  SetOptions. 
This is a point you should keep in mind if you are trying to write robust
Mathematica programs.

---------------------
Get Mathematica Tips, Tricks from  
http://www.verbeia.com/mathematica/tips/Tricks.html

Regards,
   Ted Ersek


(***** Code Starts Here ****************)

Unprotect[Message];
MyMessageList[_Integer]:= Hold[];
$ModifyMessage=True;

Message[name_,args__]/;$ModifyMessage:=
  Block[{$ModifyMessage},
    (*  If the message isn't Off it will be displayed due to evaluating the
begining of the If statement.  *)
 
If[(Message[name,args]=!=$Off[])&&(Count[MyMessageList[$Line],Unevaluated[na
me],-1]<3),
      If[ MyMessageList[$Line]===Hold[],          
        MyMessageList[$Line]=Hold[Message[name,args];],          
        (* else *)
        MyMessageList[$Line]=
 
Insert[MyMessageList[$Line],Unevaluated[Message[name,args]],{1,-2}]
      ];
    ]
  ]

Protect[Message];


FullMessageList[n_]:=
 Module[{s1,s2,s3,posn,TempHold1,TempHold2,result},
    Attributes[HoldTemp1]=Attributes[HoldTemp2]={HoldAll};
    s1=MyMessageList[n]/.m_MessageName:>HoldTemp1[m];
    s2=Apply[HoldTemp1,MessageList[n],1,Heads->False];
    s3=Map[{#,Count[s2,#]}&,Union[s2],Heads->False];
    posn=Apply[Position[s1,#1,-1,#2]&,s3,1,Heads->True];
    posn=Map[Drop[#,-1]&,Flatten[posn,1],Heads->False];
    result=Extract[MyMessageList[n]/.Message->HoldTemp2,Sort[posn] ];
    result=Apply[Hold,result ,Heads->False];
    result=Apply[HoldForm, {result}/.HoldTemp2->Message, Heads->False];
    Part[result,1,0]=CompoundExpression;
    result
 ]





  • Prev by Date: Re: Adding columns and rows to a table
  • Next by Date: RE: List operations "in a given dimension"
  • Previous by thread: Re: Re: Full text of the current warning message(s)
  • Next by thread: Re: Full text of the current warning message(s)