perm filename TRANSC.SAI[NEW,AIL] blob sn#408325 filedate 1979-01-08 generic text, type T, neo UTF8
begin "TRANSC"
   external procedure echon;
   external procedure echoff;
   external integer procedure ptyget;
   external boolean procedure hiber(integer bits,time,immed);
   external procedure ptyrel(integer chn);
   external integer procedure ptchrs(integer chn);
   external procedure ptostr(integer chn;string char);
   external integer !skip!;
   require "ptyfil.rel" load!module;
   require "hiber.rel" load!module;
   require "echos.rel" load!module;
   require "std.hdr[170,161]" source!file;
   integer chn,foundflag,inchr,topen,trachan,ttychan;
   integer outchar;
   chn←ptyget;
   echoff;

   while true do
   begin "hiberloop"
      hiber('70,10000,true);
      foundflag :=  true;

      while foundflag do
      begin
         foundflag := false;
         outchar := inchrs;
         if outchar neq -1 then
            begin
               foundflag := true;
               if outchar = "$" then
                  outchar := 3;
               if outchar = "`" then
                  outchar := '25;
               if outchar = "}" then
                  begin
                     if topen then
                        release(trachan);
                     ptyrel(chn);
                     echon;
                     print(crlf,"END of TRANSCRIPT",crlf);
                     call(0,"EXIT");
                  end;
               if outchar = "#" then
                  begin
                     if topen then
                        print(crlf,"transcript file already open",crlf)
                     else
                        begin
                           print(crlf,"transcript file name - ");
                           echon;
                           trachan := openout(inchwl);
                           echoff;
                           topen := true;
                        end;
                  end
               else if outchar = "%" then
                  begin
                     if topen then
                        begin
                           release(trachan);
                           topen := false;
                           print(crlf,"Transcript file closed",crlf);
                        end
                     else
                        print(crlf,"No transcript file to close",crlf);
                  end
               else
                  begin
                     ptostr(chn,outchar);
                     if outchar= cr then
                       ptostr(chn,lf);
                     if topen  then
                        begin
                           wordout(trachan,outchar);
                           if outchar=cr then
                           wordout(trachan,lf);
                        end;
                     outchr(outchar);
                     if outchar = cr then
                        outchr(lf);
                  end
            end;
         inchr := ptchrs(chn);
         if inchr neq -1 then
            begin
               foundflag := true;
               outchr(inchr);
               if topen and (inchr neq 0) then
                  wordout(trachan,inchr);
            end;
      end;
   end;
end "TRANSC"