MathGroup Archive 1992

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

Search the Archive

MathLink problems

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: MathLink problems
  • From: Rainer Staringer <rainer at fml.tuwien.ac.at>
  • Date: Tue, 4 Aug 1992 12:11:49 +0200

I have a few questions regarding the MathLink protocol. I am working
on a NeXTstep application for risk evaluation of option portfolios,
which needs to interface with existing Mathematica routines to do
the more complicated calculations. The MathLink documentation I
have (a booklet with 'PRELIMINARY' somewhere on the cover, and a
smaller one which contains errata) didn't help me much because it is
apparently completely out of sync with the real MathLink library -
functions having different parameters, things working
differently than advertised in the docs, etc... 


My first question is how to get the calculation parameters into
Mathematica: I could do this by passing everything as a normal
parameter to the appropriate routine; but this approach is very
inflexible because I need to hard-code the parameter passing into
the application, which makes it difficult to change the Mathematica
calculation models later on, and because it is error-prone (there
are a lot of different parameters, and the order would matter). 


I imagined the best approach would be to write a simple C function
for each of the parameters, which can then be called as an external
function from Mathematica, whenever the value is needed.
Unfortunately this complicates matters a lot, because my NeXTstep
program is then both a 'front end' and an 'external package', having
to maintain two different connections. Is the MathLink library
smart enough to do this?

My program would do something like this during initialization:

	start Mathematica subprocess using MLStart;
	eval in Mathematica: link = LinkOpen[];
	get the socket address out of the return value;
	connect to this socket using MLInit; /* Is this possible? How? */
	eval in Mathematica: Install[link];
	arrange matters so that my NeXTstep app periodically
	checks if there are callbacks to be executed using MLReady (?),
	and if yes calls MLMainStep (?) (parameters unclear in both cases).
	
Has anybody gotten something like this to work? It should be possible, if
the ML library were designed and implemented correctly, but it doesn't look
that way...

My second question: Why do you get tons of error messages if you try to
retrieve return values like they do in the sample programs? I.e.: 

	while (MLGetNextPacket (lp) != RETURNPKT)
		MLNewPacket (lp);
This generates lots of:
	Error: MLGetNextPacket called while current packet has unread data.
(or something like this). How do I tell ML that I am simply not
interested in the rest of the contents of the current packet? 


Thanks in advance for any help. I'll summarize to the mailing list as
soon as I have a working solution. 


	Rainer
---
Rainer Staringer                   | rainer at fml.tuwien.ac.at
Financial Markets Lab, TU Vienna   | +43 (1) 58801/8138

	
	





  • Prev by Date: beta-testers wanted
  • Next by Date: ISOSURFACES
  • Previous by thread: beta-testers wanted
  • Next by thread: ISOSURFACES