MathGroup Archive 1997

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

Search the Archive

Re: MathLink Activity

  • To: mathgroup at smc.vnet.net
  • Subject: [mg6326] Re: [mg6275] MathLink Activity
  • From: kevinl (Kevin Leuthold)
  • Date: Sat, 8 Mar 1997 23:26:49 -0500 (EST)
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at wolfram.com

Abdel-Aziz,

If I understand your question correctly, you want to tell
Mathematica to Get a file where certain functions are already 
defined, and evalaute those functions, given arguments that 
your program will supply.

How you do this depends on the data types of your arguments
and return values, but assuming your arguments are real,
and your functions return reals, here is one way to do it (in C):




MLPutFunction( link, "EnterTextPacket", 1);
	MLPutString( link, "Get[<name of file>];");
	MLEndPacket( link);

MLPutFunction( link, "EvaluatePacket", 1);
	MLPutFunction( link, "K1", 2);
		MLPutReal( link, x);
		MLPutReal( link, y);
	MLEndPacket( link);

/* read packets from the link until one of them is a return packet */
while( (pkt = MLNextPacket( lp), pkt) && pkt != RETURNPKT)
    MLNewPacket( lp);

MLGetReal( link, &res1);

MLPutFunction( link, "EvaluatePacket", 1);
	MLPutFunction( link, "K2", 2);
		MLPutReal( link, z);
		MLPutReal( link, h);
	MLEndPacket( link);

/* read packets from the link until one of them is a return packet */
while( (pkt = MLNextPacket( lp), pkt) && pkt != RETURNPKT)
    MLNewPacket( lp);

MLGetReal( link, &res2);

MLPutFunction( link, "EvaluatePacket", 1);
	MLPutFunction( link, "K3", 3);	
		MLPutFunction( link, "K1", 2);
			MLPutReal( link, x);
			MLPutReal( link, y);
		MLPutFunction( link, "K2", 2);
			MLPutReal( link, z);
			MLPutReal( link, h);
		MLPutReal( link, g);
	MLEndPacket( link);

/* read packets from the link until one of them is a return packet */
while( (pkt = MLNextPacket( lp), pkt) && pkt != RETURNPKT)
    MLNewPacket( lp);

MLGetReal( link, &res3);



You may already know that there is a product "MathLink for
Excel".  I'm not familiar with this product, so I can't comment
on how you would use it for your needs, only that it exists.

There is also an example of using MathLink in Visual Basic
that comes with V3.0 of Mathematica that you may want to 
look at.  It's located in the MathLink Developers' Kit, 
in the directory "UnsupportedGoodies".  This contains 
the code for a simple Visual Basic Mathematica FrontEnd, 
and a Visual Basic "header file" (actually a Visual Basic
module, to be included in VB projects) that declares all of the
MathLink functions that you would most likely need.

I hope this helps.

Kevin Leuthold
Wolfram Research


In comp.soft-sys.math.mathematica you write:

>Hi;

>I am new in the world of Mathematica, I wonder if someone could give me 
>a help with a MathLink operation. I have the followig :

>Saved in Mathematica file ::
> 3 Functions K1,K2,K3 defined in terms of 5 arguments x, y, z, h, g
> such as K1[x,y] , K2[z,h], and K3[ K1[x,y], K2[z,h], g]

>In Excel or VisualBasic ::
> I want to send "only" the values of the 5 arg. x, y, z, h, g to Mathematica
> and obtain/request the results of K1, K2, and K3. 

>If there are functions such as the MLPutFunction that can be used 
>to do this operation, please show it to me or explain how to deal with 
>it.  
> 
>Thank you very much for your help.

>Abdel-Aziz



  • Prev by Date: Re: Re: y=f(t) vs t=f(y)
  • Next by Date: Comparison of Mathematica on Various Computers
  • Previous by thread: Re: Displaying Rotated Text on a Macintosh or Sun
  • Next by thread: Comparison of Mathematica on Various Computers