MathGroup Archive 1999

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

Search the Archive

How to interrupt a running evaluation in MathLink

  • To: mathgroup at
  • Subject: [mg16896] How to interrupt a running evaluation in MathLink
  • From: rmille1 at (RMille1)
  • Date: Mon, 5 Apr 1999 02:24:29 -0400
  • Organization: AOL
  • Sender: owner-wri-mathgroup at

I'm using Mathlink in my C program to start a Mathlink kernel and send this
expression to be evaluated:

N[ReplaceAll["Some expression",x->"some variable"]]

Everything is working otay. However, occasionally an expression I send causes
the kernel to evaluate for longer than I would like it to. So what I want to do
is interrupt the evaluation and abort just as it would from a command line with
Ctr-C and abort, but through MathLink. Here's the snippet of code that will
call it:

pkt = MLFlush(Link);
interval = 0;

if(interval > 10)
dump = fopen("dump.txt","a");//test
fclose(dump);  //test

***** Interrupt and Abort here. ************
	return 0;

I know there's a way to do this with MLAbort from the kernel, but not the other
way. Also I didn't use Loopback or mprep, 

One other thing. I found the MathLink Tutorial by Todd Gayley to be the best
resource for learning how to use MathLink to start and run a Math kernel from
C. However, it seems a little dated. I'm using 

char *argv[5] = {"-linkname",
                 "c:\\progra~1\\wolfra~1\\mathem~1\\3.0\\math -mathlink",
with MLOpen(), and that doesn't jive with the documentation in Mathematica 3.0

Is there a more up to date version available?

  • Prev by Date: Mathematica Mathlink bug.
  • Next by Date: Re: extracting lhs or rhs of equations
  • Previous by thread: Re: Mathematica Mathlink bug.
  • Next by thread: Re: How to interrupt a running evaluation in MathLink