{$DOUBLE}


Program MSSndr;

{
  Description: General Message Sender
         File: [message]MSSndr.PAS
       Author: Jim Bostwick  23-NOV-1988 
    Last Edit: 19-OCT-1989 01:07:52 
      History:
     	19-OCT-1989 - JMB - Integrated Message_rec 
    	 9-OCT-1989 - JMB - Major happy munging...
	 3-AUG-1989 - JMB - Add $DOUBLE compiler switch


}

{$nolist}
{[a+,b+,l-,k+,r+] Pasmat }
%INCLUDE 'PAS$EXT:GENERAL.TYP';
%INCLUDE 'PAS$EXT:MESSAGE.PKG';
%INCLUDE 'PAS$EXT:STRING.PKG';
%INCLUDE 'Pas$ext:GTSK.TYP';
%INCLUDE 'Pas$ext:GTSK.Ext';
%INCLUDE 'PAS$EXT:CATR56.EXT';
%INCLUDE 'PAS$EXT:CR56TA.EXT';
%include 'pas$ext:tlon.ext';
%include 'pas$ext:rdef.ext';
%include 'pas$ext:clef.ext';
%include 'pas$ext:stlo.ext';
%include 'pas$ext:srda.ext';
%include 'pas$ext:wait.ext';
{$list}



var
	out_Msg: Message_rec;
	Stat, Len, pos: integer;
	done: boolean;
	r5nam:Rad56;
	Tsk_info: Task_info_rec;
	Tmp6, HisName, MyName: CH6;  { name we're running under }
	HisNode, node: CH6;    { node we're running on }
	Str,out_str: ch80;    { a useful string }


begin  { Main }
	Gtsk(tsk_Info);		     	{ find out about self }
	cr56ta(Tsk_info.Name,MyName);  	{ make it printable }
	tlon('SYS$NODE',node,len);	{ find out node name }
	sassign(str,'MSSndr operating on ');
	sconcat(str,node);
	sconcat(str,' as task ');
	sconcat(str,Myname);
	schconcat(str,'.');
	swrite(output,str);
	writeln;
	HisNode := Node; 
	Sclear(HisName);
	write('More? [^Z to end]: ');
	While Not(eof(input)) DO
	    Begin
	    readln;
	    SClear(out_Msg.comment);
    	    out_msg.id := pk_comment;
	    out_msg.sub := [];
	    write('Node [',HisNode,']: ');
	    tmp6 := HisNode;
	    sread(input,HisNode);
	    If slen(HisNode) = 0 Then HisNode := tmp6;
	    write('Task [',HisName,']: ');
	    tmp6 := HisName; 
	    sread(input,HisName);
	    if slen(HisName) = 0 Then HisName := Tmp6;
	    len := 255;
	    repeat
		write('Message [1..',len,', <cr> to end]: ');
		sread(input,str);
		len := len - slen(str);
		if slen(str) > 0 then sconcat(out_msg.comment,str);
	    until ( (slen(str) = 0) or (len = 0) );
	    Msinit(HisNode,HisName,out_msg,stat);
	    if stat = 1 THEN 
		begin
		MSsend(Out_Msg,f0);
		swrite(output,myname);
		write(output,'> ');
		swrite(output,out_msg.comment);
		Writeln(' to ',HisName,',  Mssend status = ',$dsw,'.')
		end
	    ELSE begin
		swrite(output,myname);
		write(output,'> ');
		Writeln('Msinit error, stat= ',stat)
		end;
  	    wait(f1,5,seconds);	{ let receiver talk a bit to TI: }
	    write('More? [^Z to end]: ')
	    end;
	writeln( 'Task ',Myname,' done.')
end.
