Re: How to disable automatic clearing $MessageList after generating of output?
- To: mathgroup at smc.vnet.net
- Subject: [mg116956] Re: How to disable automatic clearing $MessageList after generating of output?
- From: Alexey <lehin.p at gmail.com>
- Date: Sat, 5 Mar 2011 06:08:38 -0500 (EST)
I have found the solution. It exploits elegant hack by Todd Gayley. Here it is (of course, it must be evaluated in the slave kernel): $globalMessageList = {}; Unprotect[Message]; Message[args___] := Block[{$inMsg = True, $MessageList = $globalMessageList}, Message[args]; $globalMessageList = $MessageList; ] /; ! TrueQ[$inMsg]; Protect[Message]; One can fully emulate standard behavior of Messages in the slave kernel by checking the current value of $Line and comparing it with previous value: If[TrueQ[$Line > lastLine], LinkWrite[$kern, Unevaluated[ExpressionPacket[$globalMessageList = {};]]]; LinkRead[$kern]]; lastLine = $Line; :)