Re: Full text of the current warning message(s)
- To: mathgroup at smc.vnet.net
- Subject: [mg33537] Re: Full text of the current warning message(s)
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Fri, 29 Mar 2002 06:13:28 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Back to Vladimir Bondarenko's desire to see the full text of messages from a specific In[] line. My last solution to solve this is provided below. (* ******************* *) 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 ] (* *********************************** *) But Vladimir noted that, in the example below FullMessageList[6] doesn't correctly report the messages. In[6]:= Integrate[ArcTan[1-Sqrt[1-z^(-1)]],{z,-1,1}]; (* Several messages posted but not shown here. *) In[7]:= FullMessageList[6] Out[7] Message[$MaxExtraPrecision::meprec, -9-(82*(41-8*Sqrt[34]))/55+(41-8*Sqrt[34])^2/55, 50.]; Message[$MaxExtraPrecision::meprec, -9-(82*(41-8*Sqrt[34]))/55+(41-8*Sqrt[34])^2/55, 50.]; Message[$MaxExtraPrecision::meprec, -9-(82*(41-8*Sqrt[34]))/55+(41-8*Sqrt[34])^2/55, 50.] The next line shows all calls we had to Message[$MaxExtraPrecision::meprec,__] with the change Message->Hold to prevent messages from evaluating. Included in the result are messages that were displayed and some spurious messages with the MessageName ($MaxExtraPrecision::meprec). It turns out the first three messages below were spurious messages, and they are the ones we get from FullMessageList[6]. In[7]:= Cases[ (MyMessageList[6]/. Message->Hold), Hold[$MaxExtraPrecision::"meprec",__], -1] Out[7]= (* Long output not displayed *) I was puzzled as to why messages are evaluated, but not displayed even though they are On. I wanted to see if I could find an undocumented feature that causes messages to be supressed some of the time, so I looked into some of the contexts returned after evaluating Contexts[]. That lead me to the following feature which might provide a solution to the problem above. However, I wasn't able to figure out how it's used, and it has no documentation. Also it might be possible to solve the problem above with a ($MessagePrePrint) setting, but I couldn't get it working. It seems help from Wolrfram Research is needed to get this working any better .... and I thought I wrote a robust program. In[8]:= ??Internal`DeactivateMessages Internal`DeactivateMessages Attributes[Internal`DeactivateMessages] = {HoldAll, Protected} ------------------------------ What we are trying to do here should be a built-in feature! Regards, Ted Ersek