MathGroup Archive 2011

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

Search the Archive

(MathLink) Correct handling of Messages generated by slave kernel

  • To: mathgroup at
  • Subject: [mg116432] (MathLink) Correct handling of Messages generated by slave kernel
  • From: Alexey <lehin.p at>
  • Date: Tue, 15 Feb 2011 06:33:34 -0500 (EST)


When working through MathLink with slave kernel I have a problem with
correct parsing TextPackets. In particular when such packet
corresponds to a Message generated by the slave kernel I do not
understand how to handle it correctly at all. I need such Messages to
be printed in the evaluation notebook as if they were generated by
notebook's master kernel (but with some mark to make clear that it
comes from the slave). And I need to separate TextPackets
corresponding to Messages from those just to Print[] commands. The
last I need to parse correctly too, printing them in the evaluation
notebook with a little mark that it is from the slave kernel.

Here is an example of what happens:

link = LinkLaunch[First[$CommandLine] <> " -mathlink"]
 Unevaluated[EnterExpressionPacket[Print[a]; 1/0; Print[b]]]]
While[Not@MatchQ[packet = LinkRead[link], InputNamePacket[_]],

The message by default comes through MathLink in the form:

TextPacket[                                 1
Power::infy: Infinite expression - encountered.

It looks ugly. The only way to make it better I have found is to
evaluate in the slave kernel
$MessagePrePrint = InputForm;
But I think there should be more straightforward solution. In
particular when dealing this way I get TextPackets with HoldForms

TextPacket[Power::infy: Infinite expression HoldForm[0^(-1)]

I do not know how to convert such string into appropriate form for
displaying as a Message.

  • Prev by Date: Re: Mathematica: subscript simplification under non-communicative multiplication.
  • Next by Date: Fitting Experimental Data
  • Previous by thread: Re: How to do quickest
  • Next by thread: Fitting Experimental Data