(* Collection of code snippets by Arne Vajhøj *)
(* (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) *)
program p3(input,output);

const
   c2smbx = 'C2SMBX';
   s2cmbx = 'S2CMBX';

var
   fc2s, fs2c : text;
   outmsg, inmsg : varying [1024] of char;
   done : boolean;

begin
   (* open mailboxes *)
   open(fc2s, c2smbx + ':', new);
   rewrite(fc2s);
   open(fs2c, s2cmbx + ':', old);
   reset(fs2c);
   (* write *)
   outmsg := 'Hi from Pascal!';
   writeln(fc2s, outmsg);
   (* read *)
   done := false;
   while (not done) and (not eof(fs2c)) do begin
      readln(fs2c, inmsg);
      if inmsg = '*' then begin
         done := true;
      end else begin
         writeln('|' + inmsg + '|');
      end;
   end;
   (* close mailboxes *)
   close(fc2s);
   close(fs2c);
end.
