💾 Archived View for blitter.com › apl-books › APLX50 › APLX-manual › www.microapl.com › apl_help › c… captured on 2023-01-29 at 14:38:16.
⬅️ Previous capture (2022-07-17)
-=-=-=-=-=-=-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Communication between child and parent tasks</TITLE> <META NAME="DESCRIPTION" CONTENT="APL language help page: Communication between child and parent tasks"> <META NAME="KEYWORDS" CONTENT="Tasks,Multi-tasking,Signals,apl,aplx,apl help"> <!-- %%COMMON_HEAD%% --> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <LINK rel="stylesheet" type="text/css" href="http://www.microapl.com/styles_apl_help.css"> <!-- %%END%%--> </HEAD> <body> <table> <tr> <td width="800" valign="top" colspan="2"> <center>Topic: <A HREF="ch.htm"><code>APLX Help</code></A> : <A HREF="ch_200.htm"><code>Multi-tasking support</code></A> : <A HREF="ch_200_050.htm"><code>Communication between child and parent tasks</code></A> </center> <center> [ <A HREF="ch_200_040.htm">Previous</A> | <A HREF="ch_200_060.htm">Next</A> | <A HREF="ch.htm">Contents</A> | <A HREF="help_index.htm">Index</A> | <A HREF="http://www.microapl.co.uk/apl/index.html">APL Home</A> ]</center> <br></td> </tr> <tr> <td width="120"> <a href="http://www.microapl.co.uk/apl/index.html"><img height="68" border="0" width="119" src="MicroAPL_logo.gif" alt="www.microapl.co.uk"></a> </td> <td align="left" valign="bottom"> <h1>Communication between child and parent tasks</h1> </td> </tr> <tr> <td width="800" valign="top" colspan="2"> <hr> <p>Once a child task is running, events are used to communicate between the child and its parent. These events can arise automatically, or more usually by explicit program action. They are used to trigger the execution of a callback function in the receiving task. (Note: As with all callbacks in APLX, the actual callback is run in a <code>⎕WE</code> (wait for events) statement).</p> <p>The automatic events occur when the state of the child task changes. They are as follows (in each case, <code>⎕EV[6]</code> in index origin 1 will contain the unique task ID, as returned by the <tt>taskid</tt> property):</p> <ul> <li>When the state of the child task changes from executing to awaiting input, an <tt>onReady</tt> event is triggered in the parent's task object. You can associate a callback with this, for example to pass the next command to the child task: <p><pre> ChildTask.onReady←'NEXTCMD'</pre></p> <p>This would cause the <code>NEXTCMD</code> function to be run when the child task is ready for the next command to be sent to it using the <tt>Execute</tt> method.</p> </li> <li>When an untrapped error occurs during function execution (but not desk-calculator mode) in the child task, an <tt>onError</tt> event is triggered in the parent's task object. You can associate a callback with this, for example to write the error to a diagnostic log: <p><pre> ChildTask.onError←'ERROR_HANDLER'</pre></p> <p>This would cause the <code>ERROR_HANDLER</code> function to be run when an error is encountered in the child task. The error message (in the same format as <code>⎕ERM</code>) will be available in <code>⎕WARG</code> during the callback. (If you have an <tt>onReady</tt> callback defined as well, this will be also be triggered, after <tt>onError</tt>).</p> </li> <li>When the child task is about to execute an expression or command (either typed by the user, or under program control) an <tt>onExecute</tt> event is triggered in the parent's task object. During the callback, <code>⎕WARG</code> contains the command or expression which is about to be executed, as a character vector. This can be used for example to write an APL tutorial application when the parent task can see what the user is entering in the child-task session window.</li> <p></p> <li>Finally, when the child task is about to terminate for any reason, an <tt>onClose</tt> event is triggered in the parent's task object. </li> </ul> <hr> </td> </tr> <tr> <td width="800" valign="top" colspan="2"> <center>Topic: <A HREF="ch.htm"><code>APLX Help</code></A> : <A HREF="ch_200.htm"><code>Multi-tasking support</code></A> : <A HREF="ch_200_050.htm"><code>Communication between child and parent tasks</code></A> </center> <center> [ <A HREF="ch_200_040.htm">Previous</A> | <A HREF="ch_200_060.htm">Next</A> | <A HREF="ch.htm">Contents</A> | <A HREF="help_index.htm">Index</A> | <A HREF="http://www.microapl.co.uk/apl/index.html">APL Home</A> ]</center> <br></td> </tr> </table> <!-- %%COMMON_BODY_TAIL%% --> <p class="copyright">Copyright © 1996-2010 MicroAPL Ltd</p> <!-- %%END%% --> </body> </html>