{ PICSMAIN.INC - Pascal Integrated Communications System mainline code}
{ 5/25/87 Ver 1.6 Copyright 1987 by Les Archambault }

  procedure dummy4;
  { FORCE NEW OVERLAY }
    begin
    end;

overlay procedure initdrives;
{ Set up your destination drives }
const
  DiskIni      = 'PICS.DRV';
var
  FI           : text;
  ch           : char;

  function Drive(m:StrStd):char;
  begin
    write('Laufwerk fuer ',m:12,' (A..P) ? ');
    repeat
      repeat until keypressed;
      read(kbd,ch);
      ch:=upcase(ch);
    until ch in ['A'..'P'];
    writeln(ch);
    Drive:=ch;
  end;

begin
  assign(FI,DiskIni);
  {$I-}reset(FI){$I+};
  if (IOresult=0) then
  begin
    readln(FI,user_drv);
    readln(FI,logr_drv);
    readln(FI,mesg_drv);
    readln(FI,summ_drv);
    readln(FI,sysm_drv);
    readln(FI,sect_drv);
    readln(FI,stat_drv);
    readln(FI,nwin_drv);
    readln(FI,RcvChDrv);
    readln(FI,RcvUsr);
    close(FI);
  end else
  begin
    writeln('Disk-Definitions-Datei ',DiskIni,' nicht gefunden');
    write('Soll Datei erzeugt werden (J/N) ? ');
    repeat
      repeat until keypressed;
      read(kbd,ch);
      ch:=upcase(ch);
    until ch in ['J','N'];
    writeln(ch);
    writeln;
    if ch='J' then
    begin
      user_drv:=Drive(user_data)+':';
      logr_drv:=Drive(logr_name)+':';
      mesg_drv:=Drive(mesg_name)+':';
      summ_drv:=Drive(summ_name)+':';
      sysm_drv:=Drive(sysm_name)+':';
      sect_drv:=Drive(sect_name)+':';
      stat_drv:=Drive(stat_name)+':';
      nwin_drv:=Drive(nwin_name)+':';
      RcvChDrv:=Drive('Upload');
      repeat
        write('User Bereich fuer Uploads [0..15] ? ');
        readln(RcvUsr);
      until RcvUsr in [0..15];
      rewrite(FI);
      writeln(FI,user_drv);
      writeln(FI,logr_drv);
      writeln(FI,mesg_drv);
      writeln(FI,summ_drv);
      writeln(FI,sysm_drv);
      writeln(FI,sect_drv);
      writeln(FI,stat_drv);
      writeln(FI,nwin_drv);
      writeln(FI,RcvChDrv);
      writeln(FI,RcvUsr);
      close(FI);
    end else
    begin
      writeln('Einstellung auf Standardwerte');
      RcvChDrv:=chr(BDOS(getdrive)+ord('A'));
      user_drv:=RcvChDrv+':';
      logr_drv:=user_drv;
      mesg_drv:=user_drv;
      summ_drv:=user_drv;
      sysm_drv:=user_drv;
      sect_drv:=user_drv;
      stat_drv:=user_drv;
      nwin_drv:=user_drv;
      RcvUsr:=2;
    end;
  end;

  RcvDrv:=ord(RcvChDrv)-ord('A');
end;

overlay procedure initclock;
var hilf      : string[2];
    init_date : TaD_array;
    ch        : char;

begin
(*
     Let us set the clock now. Maybe it is set by a system
     utility e.g. DATE.COM, so allow bypassing the setting.
     ++++
     We cannot use function ask cause several inits have to
     be performed before ask will work properly.
*)
  write('Soll Uhr gestellt werden (J/N) ? ');
  repeat
    repeat until keypressed;
    read(kbd,ch);
    ch:=upcase(ch);
  until (ch in ['J','N']);
  writeln(ch);
  if ch='J' then 
  begin
    Writeln('Bitte Datum und Uhrzeit eingeben (2-stellige Eingaben)!');
    Writeln('Fehler werden nicht abgefangen... '); Writeln;
    write('Jahr    : '); readln(hilf);
    init_date[5] := strint(hilf);
    write('Monat   : '); readln(hilf);
    init_date[4] := strint(hilf);
    write('Tag     : '); readln(hilf);
    init_date[3] := strint(hilf);
    write('Stunde  : '); readln(hilf);
    init_date[2] := strint(hilf);
    write('Minuten : '); readln(hilf);
    init_date[1] := strint(hilf);
    write('Sekunden: '); readln(hilf);
    init_date[0] := strint(hilf);
    SetTAD(init_date);
  end;
end;

var
  OvrDsk : char;

begin { PICS }
  OvrDsk:=system_init;
  ovrdrive(ord(OvrDsk)-ord('@'));
  initdrives;
  initclock;
  cold_start;
  setup;
  wait_for_user;
  check_300_restrict;
  while not fini do
    begin
      login;
      if online and in_use then Set_Initial_areas;
      while online and in_use do
        begin
          if op_chat
            then op_chat := chat;
          check_time;
          make_prompt;
          writeln(USR);
          write_status_line;
          st:=prompt(st,50,'ES?M');
          if length(st)=1 then ch := st[1]
          else ch:=' ';
          if (not op_chat) then
            begin
              case mode of
                message_mode: process_messages;
                  files_mode: process_files;
                utility_mode: process_utility;
                  sysop_mode: process_sysop;
              end;
            end;
        end;
      exit_system;
      wait_for_user;
      check_300_restrict;
    end;
  system_de_init
end.

{End of PICSmain.inc }

