{$DOUBLE}

Program MSRcvr;

{
  Description: General Message receiver
         File: [message]MSRcvr.PAS
       Author: Jim Bostwick  23-NOV-1988 
    Last Edit: 20-OCT-1989 04:07:04 
      History:
         20-OCT-1989 -JMB - reduced message header
    	 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:GTSK.TYP';
%INCLUDE 'Pas$ext:GTSK.Ext';
%INCLUDE 'PAS$EXT:STRING.PKG';
%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';
{$list}



CONST
	die_efn = f90;
	rcv_efn = f91;
var
	In_Msg: Message_rec;
	Stat, Len, pos: integer;
	done: boolean;
	r5nam:Rad56;
	Tsk_info: Task_info_rec;
	MyName: CH6;  { name we're running under }
	node: CH6;    { node we're running on }
	Str,out_str: ch80;    { a useful string }


{ Procedure to dump DSW and header }
Procedure Dump_hdr(Var h:Message_Rec);

VAR
	nam: CH6;
BEGIN
	write('And the status is ',$DSW);
        dmphdr(output,h)
end;



begin  { Main }
	clef(die_efn);
	clef(rcv_efn);
	srda(rcv_efn);
	done := false;
	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,'MSRcvr operating on ');
	sconcat(str,node);
	sconcat(str,' as task ');
	sconcat(str,Myname);
	swrite(output,str);
	writeln;
	repeat
	    stlo([rcv_efn,die_efn]);
	    if rdef(rcv_efn) then 
		begin
		clef(rcv_efn);
		MSRcv(null_task_name,In_Msg);
		Dump_Hdr(In_Msg);
		Writeln('  and the text is:');
		len := slen(In_msg.comment);
		pos := 1;
		While len >= 70 do 
		    begin
		    ssubstr(str,in_msg.comment,pos,70);
		    sassign(out_str,'>>>>|');
		    sconcat(out_str,str);
		    swrite(output,out_str);
		    writeln(output);
		    pos := pos + 70;
		    len := len - 70
		    end;
		if (len > 0) then 
		    begin
		    ssubstr(str,in_msg.comment,pos,len);
		    sassign(out_str,'>>>>|');
		    sconcat(out_str,str);
		    swrite(output,out_str);
		    writeln(output)
		    end	
		end;
	    done := rdef(die_efn)
	until done;	
	writeln( 'done.')
end.
    
 
