MathGroup Archive 1999

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

Search the Archive

Re: Math Link question about String transfer

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17518] Re: [mg17482] Math Link question about String transfer
  • From: John Fultz <jfultz>
  • Date: Mon, 10 May 1999 19:53:21 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

> How do I declare a function in the .tm file so that mprep will read my
> string argument using MLGetByteString instead of MLGetString? I am
> transfering a bitmap using a string since it is so much faster. 
> Maybe MLGetString is ok, but I need to do something to make sure my string
> does not get transformed in a bunch of "/123/432/020...".
> 
> Maybe there is another around this altogether. Of course I am trying to
> avoid going Manual, which has been my solution so far.
> 
> thanks.
> 
> Luc Barthelet
> General Manager
> Maxis
> http://www.simcity.com

I took care of this problem in FastBinaryFiles (which was originally
written by Todd Gayley, but I did the port to 3.0 MathLink) by
adding the following at the top of the .tm file:

#if defined(MLVERSION) && (MLVERSION >= 3)
#	define MLPutString(ml, str) MLPutByteString(ml, str, strlen(str))
#	define MLGetString(ml, str) MLGetByteString(ml, str, &mlgettmp, 255)
#	define MLDisownString(ml, str) MLDisownByteString(ml, str, mlgettmp)
long mlgettmp;
#endif /* MLVERSION */

While I admit that this is a rather crude and sledgehammer-like method
of solving the problem (in particular, it allows for no legitimate uses
of MLGet/PutString in your code), it did work for my case (my problem
had to do with the doubling of backslashes introduced by
MLGet/PutString).

You would need to make sure to pay attention to the value of 'mlgettmp'
since you cannot assume your strings are NULL-terminated, and there is
an implicit assumption that you'll never get/put more than one string
at a time (i.e. the installable function only takes one string).

								-John


  • Prev by Date: Re(2): Re: Bug in Solve?
  • Next by Date: Export of postscript
  • Previous by thread: Math Link question about String transfer
  • Next by thread: Re: Math Link question about String transfer