
unit minitool;


interface

uses crt,dos,rwptool;

(*************************************************************************)

const logfile  : string  = 'MINITERM.LOG';
      logopen  : boolean = false;
      dolog    : boolean = true;

var   lf       : text;

(*************************************************************************)

procedure startlog(s:string);

procedure openlogfile;

procedure closelogfile;

procedure writelogfile(s:string);


(*************************************************************************)

implementation


(*************************************************************************)

procedure startlog(s:string);
var io:integer;
begin
    {$I-}
    writeln(lf,Uhrzeittext,'  INIT : ',s);
    io:=ioresult;
    {$I+}
    writeln(s);
end;

(*************************************************************************)

procedure openlogfile;
var io,io2 : integer;
begin
   if not logopen then begin
      assign(lf,logfile);
      {$I-}
      reset(lf);
      io:=ioresult;
      close(lf);
      io2:=ioresult;
      if io=0 then begin
           append(lf);
           io:=ioresult;
           end
      else if io=2 then begin
           rewrite(lf);
           io:=ioresult;
           end;
      if io=0 then begin
           writeln(lf,#13+#10+DatumZeit,
                   ' Starting Log.');
           io:=ioresult;
           logopen:=true;
           end
      else begin
           logopen:=false;
           dolog:=false;
           writeln;
           writeln('ERROR opening logfile (',logfile,').');
           writeln('no logging available.');
           writeln;
           end;
      {$I+}
      end;
end;

procedure closelogfile;
var io : integer;
begin
    if logopen then begin
       {$I-}
       if dolog then begin
          writeln(lf,#13+#10+DatumZeit+'  End logging.');
          io:=ioresult;
          end;
       close(lf);
       io:=ioresult;
       {$I+}
       end;
end;

procedure writelogfile(s:string);
var io : integer;
begin
    if logopen and dolog then begin
       {$I-}
       write(lf,s);
       io:=ioresult;
       {$I+}
       end;
end;



end.