Re: package functions in mathlink
- To: mathgroup at smc.vnet.net
- Subject: [mg43606] Re: package functions in mathlink
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Tue, 23 Sep 2003 04:01:56 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <bkjru0$hqt$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, you have to wait for a return packed, otherwise you get a lot of information like the In[] prompt ... If you wish to ignore all other packets : while(MLNextPacket(stdlink) !=RETURNPKT) MLNewPacket(stdlink); MLGetInteger(stdlink,&myresult); should work ... Regards Jens 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