Re: package functions in mathlink
- To: mathgroup at smc.vnet.net
- Subject: [mg43596] Re: [mg43571] package functions in mathlink
- From: John Fultz <jfultz at wolfram.com>
- Date: Tue, 23 Sep 2003 04:01:40 -0400 (EDT)
- Reply-to: jfultz at wolfram.com
- Sender: owner-wri-mathgroup at wolfram.com
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? Sincerely, John Fultz jfultz at wolfram.com 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"); >MLEndPacket(link); > >and then call it using > >MLPutFunction(link, "EvaluatePacket", 1); >MLPutFunction(link, "simpfun", 2); >MLPutInteger(link, 4); >MLPutInteger(link, 2); >MLEndPacket(link); > >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? > >Peter