˙%begin;                        !MOUSES mail system V0.0;   A. Culloch
   %include "Sysinc:command.inc"
   %external %string(17) %spec command prompt
   %record %format parm fm (%shortinteger dsno,dact,ssno,sact, %c
                            %integer p1,p2,p3,p4,p5,p6)
   %record(parm fm) P
   %integer del
   %integer exclam = command_modifier
   %const %integer status = 18
   %const %integer process info = 14
   %const %integer pack filename = 17
   %const %integer unpack filename = 18
   %const %integer to director = 20
   %const %integer delete = 14
   %const %integer become = 27
   %const %integer input ended = 9
   %externalpredicatespec Exists(%string(31) File)
   %string(*)%name sn
   %routine stop
      %record(parm fm) P
      P_p2 = 0;  P_p6 = 0;  P_dact = become
      SVC (to director,P)
      command prompt = "Command:";   !save confusion for BECOME's users
      %stop
   %end
   P_p1 = 0;  P_p2 = x'D417A';  P_p3 = x'1BE81D81';  P_p6 = 0
   select input (0);  select output (0)
   P_dact = become;  SVC (to director,P)
   P_p1 = 0;  SVC (process info,P);      !find out own process name
   P_p1 = 0;  P_p3 = 0;  P_p4 = 0
   SVC (unpack filename,P)
   sn == string(addr(P_sact));           !unpacked proc nam.
   length(sn) = length(sn) - 1;          !kill ':'
   %if %not exists (sn) %start
      print string ("No mail.")
      newline
      stop
   %finish
   select output (0)
   open input (2,sn)
   %if exclam # 0 %start;            !MAIL?
      %begin
         %integer n
         %on input ended %start
            %if n = 1 %then print string ("One") %else write (n,0)
            print string (" message")
            print symbol ('s') %if n # 1
            print string (" pending")
            newline
            stop
         %finish
         select input (2);  skip symbol %if next symbol = '*'
         n = 0
         %cycle
            %while next symbol # NL %cycle
               print symbol (next symbol) %if exclam = '?'
               skip symbol
            %repeat
            newline %if exclam˙ = '?'
            n = n + 1
            skip symbol %while next symbol # 0
            skip symbol
         %repeat
      %end
   %finish
   open output (2,sn)
   open input (3,sn);  !look at MAIL:ME
   del = 1
   %begin
      %on input ended %start; %return; %finish
      select input (2);  skip symbol %if next symbol = '*'
      select input (3);  skip symbol %if next symbol = '*'
      %cycle
         %if next symbol = 0 %start;         !NULL separates messages
            newline
            prompt ("Delete? ")
            select input (0)
            skip symbol %while next symbol <= ' '
            %if 'y' # next symbol # 'Y' %start
               !Don't delete this message
               del = 0;                      ! => don't delete file at close
               select input (2)
               select output(2)
               %while next symbol # 0 %cycle;!copy mess into new file
                  print symbol (next symbol)
                  skip symbol
               %repeat
               print symbol (0)
               skip symbol; !0
            %else
               select input (2)
               skip symbol %while next symbol # 0;   !delete message
               skip symbol
            %finish
            select input (0)
            skip symbol %while next symbol # NL
            select input (3)
            select output(0)
            skip symbol; !0
            %continue
         %finish
         print symbol (next symbol)
         skip symbol
      %repeat
   %end
   close input; !3
   select input (2)
   close input
   select output (2)
   close output
   SVC (pack filename,P)
   P_dact = delete;  SVC (to director,P) %if del # 0
   stop
%end %of %program
 