Q: LinkInterrupt[link]
- To: mathgroup at smc.vnet.net
- Subject: [mg16856] Q: LinkInterrupt[link]
- From: tobiasoed at my-dejanews.com
- Date: Thu, 1 Apr 1999 21:35:26 -0500
- Organization: Deja News - The Leader in Internet Discussion
- Sender: owner-wri-mathgroup at wolfram.com
Has one of you ever tried the example using LinkInterrupt[] p. 659 of The
Book? It goes like this:
(* launch a new mathematica kernel and communicate with it through mathlink *)
In[1]:= l=LinkCreate["math -mathlink -linkmode
ParentConnect",LinkMode->Launch] Out[1]= LinkObject[math -mathlink -linkmode
ParentConnect, 1, 1]
(* read the first prompt from the link *)
In[2]:= LinkRead[l]
Out[2]= InputNamePacket[In[1]:= ]
(* let the new kernel do some lengthly calculation *)
In[3]:= LinkWrite[l,EnterTextPacket["FactorInteger[2^177-1]"]]
(* interrupt this calculation *)
In[4]:= LinkInterrupt[l]
(* read the interrupt menu prompt from the link *)
In[5]:= LinkRead[l]
Out[5]= MenuPacket[1, Interrupt> ]
Here the example stops.
Lets try to abort the calculation
In[6]:= LinkWrite[l,TextPacket["a"]]
(* read the output and the next prompt *)
In[7]:= LinkRead[l]
Out[7]= OutputNamePacket[Out[1]= ]
In[8]:= LinkRead[l]
Out[8]= ReturnTextPacket[$Aborted]
In[9]:= LinkRead[l]
Out[9]= InputNamePacket[In[2]:= ]
Everything works as one would expect.
Let's now try to trace a caluculation instead of aborting it:
(* start the lenghly calculation again and interrupt it *)
In[10]:= LinkWrite[l,EnterTextPacket["FactorInteger[2^177-1]"]]
In[11]:= LinkInterrupt[l]
In[12]:= LinkRead[l]
Out[12]= MenuPacket[1, Interrupt> ]
(* trace the calculation *)
In[13]:= LinkWrite[l,TextPacket["t"]]
(* read the output *)
In[14]:= LinkRead[l]
Out[14]= TextPacket[long multiplication]
In[15]:= LinkRead[l]
Out[15]= TextPacket[long multiplication]
In[16]:= LinkRead[l]
LinkObject::linkd:
LinkObject[math -mathlink -linkmode ParentConnect, 1, 1]
is closed; the connection is dead.
Out[16]= $Failed
Why does the link die? what do I do wrong here ?
Tobias
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own