Program TSTCNCT;

{ File: [22,311]TSTCNCT.PAS      Last edit: 8-MAY-1989 17:23:59 
  
  History:

    8-May-89.  Philip Hannay.  Created.


  Test the P3UTIL CNCT (connect) procedure.   Accepts a command line with
  the name of the task to connect to, or will prompt for that task name.

}

{[A+,B+, K+, L-, R+] Pasmat Directive }

%include pas$ext:general.typ;
%include pas$ext:spawn.typ;

%include pas$ext:cnct.ext;
%include pas$ext:catr56.ext;  
%include pas$ext:stse.ext;

{ Use predefined pascal procedure GMCR to get MCR command line if any }
procedure GMCR;external;

Var
  task_name: ch6;
  rad_task_name: rad56;
  connect_block: spawn_status_array;
  dir_stat: integer;
  cmd_line: ch40;
  i: integer;

Begin
GMCR;
readln(cmd_line);
if cmd_line[1] = ' '
  then begin
    Writeln;
    Writeln('Test CNCT (connect) procedure...');
    Writeln;
    Write('Enter name of task (offspring) to connect to> ');
    Readln(task_name);
    end
  else begin
    writeln;
    for i:= 1 to 6 do task_name[i]:= cmd_line[i];
    end;
catr56(task_name,rad_task_name);
cnct(rad_task_name,f1,connect_block);
dir_stat:= $dsw;
if dir_stat = 1
  then begin
    writeln('  connect done successfully, wait for offspring task to exit');
    stse(f1);
    writeln('  offspring task exited, status is ', connect_block.exit_code:1);
    end
  else begin
    writeln('  unable to connect, $DSW = ',dir_stat:1);
    end;
writeln;
writeln('done with CNCT test');
writeln;
end.
