Seeing truncated messages in Mathematica

后端 未结 4 979
天涯浪人
天涯浪人 2020-12-16 22:55

Is it possible to see full version of a Message that got truncated? IE, I see something along the lines of 0.105309,0.394682,<<20>>,<<20

4条回答
  •  甜味超标
    2020-12-16 23:08

    I'm not sure if you can recover a long message that has already been generated. As $MessageList and Message[] only store the message names, not the arguments passed to them.

    To stop Short[] from being automatically applied to messages you can Unset[$MessagePrePrint]. It's default value is Automatic -- whatever that entails.


    Rather than print long messages all the time, it might be better to use something like

    General::longmsg="A long message (`1`) was produced. The full message has been saved in `2`";
    $MessagePrePrint=With[{bc=ByteCount[#]},If[bc>65536,
      With[{fn=FileNameJoin[{$HomeDirectory,StringJoin["MmaMsg",ToString/@DateList[]]}]},
        Put[#,fn];Message[General::longmsg,bc,Row[{fn}]];Short[Shallow[#],1]],
      #]]&;
    

    This will print out the message as normal unless the ByteCount is too large ( > 65536) in which case it will print out two messages: The first informs you that a large message was produced and gives you the file where it was saved. The second is the truncated version of the full message.

提交回复
热议问题