program configer (input, output, diskfile);
uses crt, dos;
const
  filename = 'config';
  SpinChar : Array [1..4] of Char = ('³','/','Ä','\');

var
  diskfile :Text;
  bbs      :integer;
  path     :string;
  bbsname  :string;
  sysopname:string;
  lockrate :longint;

Procedure CursorSize(SType, Size : Char);

Var
  Regs : Registers;
  i : Integer;

begin
  Size := UpCase(Size);
  if UpCase(SType) = 'M' then
    i := 6
  ELSE
   i := 0;

Regs.AH := $01;
CASE Size of
'O' :
  begin
   Regs.CH := $20;
   Regs.CL := $20;
  end;
'B' :
  begin
   Regs.CH := $0;
   Regs.CL := $7 + i;
  end;
'S' :
  begin
   Regs.CH := $6+i;
   Regs.CL := $7+i;
  end;
end;
Intr($10, Regs);
end;


Function ReadKeySpin(Wait : Byte) : Char;
Var
  X,Y  : Byte;
  Num  : Byte;
  Ch   : Char;
begin
  Num := 1;                               (* initialize SpinChars  *)
  X   := WhereX;                          (* Where am I ??         *)
  Y   := WhereY;
  Repeat
    Write(SpinChar[Num]);           (* Spin the Cursor       *)
    GotoXY(X, Y);                   (* Go back               *)
    Delay(Wait);                    (* Wait, it's to fast!   *)
    Write(#32);                     (* Clean Screen          *)
    GotoXY(X, Y);                   (* Go back               *)
    Inc(Num);                       (* Next SpinChar, please *)
    if Num = 5 then Num := 1;       (* I have only 5 Chars   *)
  Until KeyPressed;
  Ch := ReadKey;                        (* Get the pressed Key   *)
  Write(Ch);                            (* and Write it to screen*)
  ReadKeySpin := Ch;                    (* give a result         *)
end;

Function ReadStringSpin : String;
Var
  Help : String;
  Ch   : Char;
  i    : Byte;
begin
  Help := '';
  Repeat
    Ch := ReadKeySpin(40);
    if Ch <> #13 then Help := Help + Ch;
  Until Ch = #13;
  ReadStringSpin := Help;
  WriteLn;
end;

procedure menu;
var
  correct:char;
begin {menu}
  Assign (DiskFile, Filename);
  Rewrite (DiskFile);
  textcolor (4);
  writeLn ('Choose your BBS type:');
  textcolor (5);
  writeLn ('1.  PCBoard');
  writeLn ('2.  GAP (Door.sys)');
  writeLn ('3.  SpitFire');
  writeLn ('4.  RBBS');
  writeLn ('5.  Wildcat');
  writeLn ('6.  TriBBS');
  writeLn ('7.  WWIV');
  textcolor (8);
  write ('[   ]');
  write(' ');
  cursorsize ('c','o');
  window (3,9,4,9);
  {$I-}
  readLn (BBS);
  {$I+}
  While (IOResult <> 0) or (BBS < 1) or (BBS > 7) do
    begin {error}
     clrscr;
     {$I-}
     readLn (BBS);
     {$I+}
    end;  {error}
  if bbs = 1
    then writeLn (diskfile, 'PCB')
    else if bbs = 2
      then writeLn (diskfile, 'GAP')
    else if bbs = 3
      then writeLn (diskfile, 'SF')
    else if bbs = 4
      then writeLn (diskfile, 'RBBS')
    else if bbs = 5
      then writeLn (diskfile, 'WC')
    else if bbs = 6
      then writeLn (diskfile, 'TRIBBS')
    else if bbs = 7
      then writeLn (diskfile, 'WWIV');
  window (1,1,80,25);
  gotoxy (1,10);
  textcolor (9);
  writeLn ('What is your path to the door data files (EX: C:\doors\trivia)');
  path := readstringspin;
  writeLn (diskfile, path);
  write ('What is your BBS called: ');
  bbsname := readstringspin;
  writeLn (diskfile, bbsname);
  write ('What is your name: ');
  sysopname := readstringspin;
  writeLn (diskfile, sysopname);
  cursorsize ('m','b');
  write ('What is your locked Buad Rate: ');
  {$I-}
  readLn (lockrate);
  {$I+}
  While (IOResult <> 0) or (lockrate < 300) do
    begin {error}
      {$I-}
      write ('Bad Value please enter again: ');
      readLn (lockrate);
      {$I+}
    end;  {error}
  writeLn (diskfile, lockrate);
  close (diskfile);
  writeLn ('Writing Config File Now!');
end;  {menu}

begin {main}
  clrscr;
  menu;
  cursorsize ('c','s');
end.
