12 Multiple Task Programming
NOTE: To execute a program that contains the REQUEST# and ATTACH # statements, start Eloquence by typing eloq and then run the program from within Eloquence. If you start Eloquence by typing eloq program name when you have a program that contains these statements, the program sets up a secondary task and then the same program that started the secondary task runs in the secondary task. In other words, the same program running in the primary task runs in the secondary task.
REQUEST # taskid [,result]
It requests the ownership of a secondary task whose taskid is specified. The optional result parameter indicates the outcome of the request. Omitting this parameter will cause an execution error if the request is unsuccessful. This statement must be executed successfully before a subsequent ATTACH # statement can be executed for the corresponding taskid.
ATTACH # taskid [,result]
Its function is to switch the terminal from the executing primary task to the designated secondary task whose taskid is specified. The optional result parameter indicates the outcome of the statement. Omitting this parameter will cause an execution error if the statement is unsuccessful. The secondary task must have previously been REQUESTed by the primary task. Note that when you attach to a secondary task, the primary task continues to operate.
Operator control (that is, the terminal) is passed to the DETACHed task executing the ATTACH statement. The ATTACH statement can be executed in primary or secondary task. However, if executed in a secondary task and the terminal is assigned to another secondary task (another ATTACH #), it will be ignored.
10 DETACH 20 WAIT 5000 30 DISP "Done!" 40 ATTACH 50 ENDATTACH to a secondary task; run the program. The terminal will switch back to primary task if executing DETACH statement. After 5 seconds the terminal will switch back to secondary task.
Operator control (that is, the terminal), is passed from the secondary task to the primary task that owns it.
The DETACH statement can also be executed by pressing CTRL D. This can be used when the user is unable to enter the DETACH statement because the keyboard is not enabled.
Its function is to terminate the ownership of the specified secondary task. After this statement is issued, another primary task can then REQUEST that secondary task number.
NOTE: If this statement is issued while a program is still running in the secondary task, that program will abort.