MathGroup Archive 2003

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

Search the Archive

Re: package functions in mathlink

  • To: mathgroup at
  • Subject: [mg43596] Re: [mg43571] package functions in mathlink
  • From: John Fultz <jfultz at>
  • Date: Tue, 23 Sep 2003 04:01:40 -0400 (EDT)
  • Reply-to: jfultz at
  • Sender: owner-wri-mathgroup at

I thought your functions should work, but I compiled and tested to make 
sure, and indeed they do.  Things I would look into...

* Are you properly cleaning up packets?  You have to clear everything up 
to the InputNamePacket when first launching the kernel, and again clear 
everything up to the next InputNamePacket after using EnterTextPacket.  
You'll know you've done that if the next packet you get after sending the 
EvaluatePacket is a ReturnPacket.

* Do the "<</home/..." and subsequent simpfun commands actually work from 
a raw Mathematica kernel.  Given the symptoms you're experiencing, it 
seems like this is probably the issue.  Perhaps a typo in the string or in 
the package itself?


John Fultz
jfultz at
User Interface Group
Wolfram Research, Inc.

On Sun, 21 Sep 2003 05:42:12 -0400 (EDT), Peter Saffrey wrote:
>I have defined a package which I would then like to interact with via
>mathlink. The relevant part of the package simply looks like this:
>simpfun[x_, y_] := x - y
>I open the package by using
>MLPutFunction(link, "EnterTextPacket", 1);
>MLPutString(link, "<</home/pzs/workspace/mathematica/testpackage.m");
>and then call it using
>MLPutFunction(link, "EvaluatePacket", 1);
>MLPutFunction(link, "simpfun", 2);
>MLPutInteger(link, 4);
>MLPutInteger(link, 2);
>But rather than getting back an integer answer, I am returned an
>expression that contains the complete function call. I feel sure I
>must be using the wrong packet passing function, but EvaluatePacket
>seems appropriate. What am I doing wrong?

  • Prev by Date: Re: Simplify doesn't factor out 16 :-(
  • Next by Date: Eigenvalues, any suggestions?
  • Previous by thread: Re: package functions in mathlink
  • Next by thread: Proper way to free memory?