MathGroup Archive 2002

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

Search the Archive

Re: Error handling with MathLink

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37317] Re: [mg37287] Error handling with MathLink
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Wed, 23 Oct 2002 02:56:52 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On Tuesday, October 22, 2002, at 04:47 AM, Y.A.Tesiram wrote:

> G'day all,
> How do I return errors to Mathematica from a MathLink program?
>
> For e.g.
>
> 	...
> 	ptr = malloc( HUGE_VAL );
> 	if (ptr == NULL) {
> 		// How do I return an error value to mathematica here?
> 	}
>
>

Simply put the information into the link.  For example here is an error 
check in some of my MathLink code:

MLCheckFunction( stdlink, list, &len);
	if (len != c) {
		MLEvaluateString( stdlink, "Message[GUPTRI::sizemsmtch]");
		MLPutNext( stdlink, MLTKSYM);
		MLPutSymbol( stdlink, "$Failed");
                 goto finish;
	}

The finish label simply terminates the program.  You can put the 
messages into the .tm file with Evaluate lines.

Regards,

Ssezi



  • Prev by Date: Problems during the start of mathematica 4.0
  • Next by Date: Re: Problem with PDF generation from Mathematica
  • Previous by thread: Error handling with MathLink
  • Next by thread: Re: Error handling with MathLink