uses dos,crt,pullmode,records;

Procedure fileedit; External; {$L fileedit.obj}

type        arearec=record
            name:string[30];
            filename:string[12];
            path:string[50];
            password:String[30];
            acs:string[30];
            SPONSER:STRING[30];
            maxfiles:integer;
            free:boolean;
            pointsk:byte;
            ulacs:string[30];
            dlacs:string[30];
            listacs:string[30];
            commish:boolean;
            end;

var pm:pulld;
    areai:AREAREC;
    areaf:file of arearec;

Procedure Read_In_Config;
Var Temp : String;
 begin
   assign(configf,'LUCID.CFG');
 {$I-}   reset(configf); {$I+}
    if ioresult<>0 then begin
                        writeln('lucid.cfg Does Not Exist, Please Configur Lucid ');
                        halt(1);
                        end;
{    writeinitbox('Reading In Configuration');}
  {--}
   With Config do
    Begin
     Readln(ConfigF,LongName);
     Readln(ConfigF,Shortname);
     Readln(ConfigF,SysOpName);
     Readln(ConfigF,BoardPhone);
     Readln(ConfigF,RegistrationCode);
     Readln(ConfigF,NodeNumber);
     Readln(ConfigF,TotalNodes);
     Readln(ConfigF,DefaultUserNote);
     Readln(ConfigF,Temp);
     If Pos('T',Temp) <> 0 then Use_NUV := True else Use_NUV := False;
     Readln(ConfigF,Temp);
     If Pos('T',Temp) <> 0 then Use_SPW := True else Use_SPW := False;
    {----------------------- Passwords & Shit ----------------------}
     Readln(ConfigF,NUPS[1]);
     Readln(ConfigF,NUPS[2]);
     Readln(ConfigF,NUPS[3]);
     Readln(ConfigF,NUPS[4]);
     Readln(ConfigF,NUPS[5]);
     Readln(ConfigF,NUPAccess[1]);
     Readln(ConfigF,NUPAccess[2]);
     Readln(ConfigF,NUPAccess[3]);
     Readln(ConfigF,NUPAccess[4]);
     Readln(ConfigF,NUPAccess[5]);
     Readln(ConfigF,SystemPW);
     Readln(ConfigF,BadBaudPW);
     Readln(ConfigF,ShellPW);
     Readln(ConfigF,ExitPW);
     Readln(ConfigF,SysOpPW);
     Readln(ConfigF,ChatPW);
    {------------------------- Directory Shit ----------------------}
    Readln(ConfigF,Lucid_dir);
    Readln(ConfigF,Text_dir);
    Readln(ConfigF,Board_Dir);
    Readln(ConfigF,Data_Dir);
    Readln(ConfigF,Textfile_dir);
    Readln(ConfigF,Door_dir);
    Readln(ConfigF,work_dir);
    Readln(ConfigF,Extract_dir);
    {-------------------------- Modem Shit -------------------------}
    Readln(ConfigF,Comport);
    Readln(ConfigF,LockBaud);
    Readln(ConfigF,LowestBaud);
    Readln(ConfigF,AnswerStr);
    Readln(ConfigF,InitStr);
   End;
  close(configf);
end;

Procedure editline (Var S : String;BUF:BYTE);
Var Ch : Char;
    X:INTEGER;
    sx,sy:integer;
    buflen:byte;
Begin
  BUFLEN:=BUF;
  textcolor(15);
  textbackground(4);
  sx:=wherex;
  sy:=wherey;
  for x:=1 to buflen do write('°');
  gotoxy(sx,sy);
  X:=1;
  write(S);
  x:=length(s);
  Repeat
    Ch := ReadKey;
    IF X<BUFLEN THEN
    If Ord (Ch) in [32..255] Then
    Begin
      INC(X);
      S := S + Ch;
      write(ch);
          End;
    If Ord (Ch) = Ord (8) Then
    Begin
      If Length (S) > 0 Then
      Begin
        Write (#8'°'#8);
        Delete (S, Length (S), 1);
        DEC(X);
      End;
    End;
  Until (Ord (Ch) = 13);
  Write (#13#10);
End;

procedure display;
var t:text;
    c:char;
begin
move(Pointer(@fileedit)^,ptr($B800,0)^,3660);
end;

procedure setupbar;
VAR X:BYTE;
begin
fillchar(pm,sizeof(pm),#0);
PM.CH[1] :='A';
PM.CH[2] :='B';
PM.CH[3] :='C';
PM.CH[4] :='D';
PM.CH[5] :='E';
PM.CH[6] :='F';
PM.CH[7] :='G';
PM.CH[8] :='H';
PM.CH[9] :='I';
PM.CH[10]:='J';
PM.CH[11]:='K';
PM.CH[12]:='L';
PM.CH[13]:='M';
PM.CH[14]:='!';
PM.CH[15]:='@';
PM.CH[16]:='[';
PM.CH[17]:=']';
PM.CH[18]:='X';

pm.ON[1]:='|B1|15(a)';
pm.ON[2]:='|B1|15(b)';
pm.ON[3]:='|B1|15(c)';
pm.ON[4]:='|B1|15(d)';
pm.ON[5]:='|B1|15(e)';
pm.ON[6]:='|B1|15(f)';
pm.ON[7]:='|B1|15(g)';
pm.ON[8]:='|B1|15(h)';
pm.ON[9]:='|B1|15(i)';
pm.ON[10]:='|B1|15(j)';
pm.ON[11]:='|B1|15(k)';
pm.ON[12]:='|B1|15(l)';
pm.ON[13]:='|B1|15(m)';
pm.ON[14]:='|B1|15(!)';
pm.ON[15]:='|B1|15(@)';
pm.ON[16]:='|B1|15(])';
pm.ON[17]:='|B1|15([)';
pm.ON[18]:='|B1|15(x)';

pm.off[1]:='|B0|01(|09a|01)';
pm.off[2]:='|B0|01(|09b|01)';
pm.off[3]:='|B0|01(|09c|01)';
pm.off[4]:='|B0|01(|09d|01)';
pm.off[5]:='|B0|01(|09e|01)';
pm.off[6]:='|B0|01(|09f|01)';
pm.off[7]:='|B0|01(|09g|01)';
pm.off[8]:='|B0|01(|09h|01)';
pm.off[9]:='|B0|01(|09i|01)';
pm.off[10]:='|B0|01(|09j|01)';
pm.off[11]:='|B0|01(|09k|01)';
pm.off[12]:='|B0|01(|09l|01)';
pm.off[13]:='|B0|01(|09m|01)';
pm.off[14]:='|B0|01(|09!|01)';
pm.off[15]:='|B0|01(|09@|01)';
pm.off[16]:='|B0|01(|09]|01)';
pm.off[17]:='|B0|01(|09[|01)';
pm.off[18]:='|B0|01(|09x|01)';

FOR X:=1 TO 18 DO BEGIN
                   PM.CX[X]:=9;
                   PM.CY[X]:=4+X;
                   END;
PM.MAXC:=18;
PM.CURRENTCHOICE:=1;
end;

procedure showinfo;
var x:integer;
begin
textattr:=15;
for x:=1 to 18 do begin
                  gotoxy(18,3+x);
                  end;
textattr:=15;
gotoxy(26,5);
write(areai.name);
gotoxy(26,6);
write(areai.filename);
gotoxy(26,7);
write(areai.path);
gotoxy(26,8);
write(areai.password);
gotoxy(26,9);
write(areai.acs);
gotoxy(26,10);
write(areai.sponser);
gotoxy(26,11);
write(areai.maxfiles);
gotoxy(26,12);
write(areai.free);
gotoxy(26,13);
write(areai.pointsk);
gotoxy(26,14);
write(areai.ulacs);
gotoxy(26,15);
write(areai.dlacs);
gotoxy(26,16);
write(areai.listacs);
gotoxy(26,17);
write(areai.commish);
end;

procedure nextarea;
begin
if filepos(areaf)=filesize(areaf) then seek(Areaf,0);
read(areaf,areai);
end;

procedure prevarea;
begin
if filepos(areaf)=1 then seek(areaf,filesize(areaf)+1);
seek(areaf,filepos(areaf)-2);
read(areaf,areai);
end;

FUNCTION YESNO(B:BOOLEAN):BOOLEAN;
BEGIN
IF B=TRUE THEN YESNO:=FALSE ELSE YESNO:=TRUE;
END;

PROCEDURE DELETEIT;
VAR SX:INTEGER;
BEGIN
IF FILESIZE(AREAF)>1 THEN BEGIN
                                         SX:=FILEPOS(AREAF)-1;
                                         IF SX=FILESIZE(aREAF)-1 THEN
                                            BEGIN
                                            SEEK(AREAF,FILESIZE(AREAF)-1);
                                            TRUNCATE(AREAF);
                                            SEEK(AREAF,FILESIZE(AREAF)-1);
                                            READ(AREAF,AREAI);
                                            SHOWINFO;
                                            EXIT;                                            EXIT;
                                            END;

                                         REPEAT
                                         SEEK(AREAF,SX+1);
                                         READ(AREAF,AREAI);
                                         SEEK(AREAF,SX);
                                         WRITE(aREAF,AREAI);
                                         INC(SX);
                                         UNTIL SX=FILESIZE(AREAF)-1;
                                         TRUNCATE(AREAF);
                                         END;

END;

PROCEDURE ADDAREA;
    var int:byte;
        S:STRING;
        SX:INTEGER;
BEGIN
display;
SETUPBAR;
FILLCHAR(areai,SIZEOF(areai),#0);
assign(areaf,config.data_dir+'filearea.dat');
{$I-} RESET(AREAF); {$I+}
if ioresult<>0 then begin
                    rewrite(areaf);
                    areai.name:='Misc Area';
                    areai.filename:='MISC.DAT';
                    areai.path:='C:\';
                    areai.password:='';
                    areai.acs:='';
                    areai.sponser:='Judge Dredd';
                    areai.maxfiles:=9999;
                    areai.free:=false;
                    areai.pointsk:=10;
                    areai.ulacs:='';
                    areai.dlacs:='';
                    areai.listacs:='';
                    areai.commish:=false;
                    write(areaf,areai);
                    end;
                    reset(areaf);
                    read(areaf,areai);

showinfo;
repeat
int:=PULLMENU(PM);
IF INT IN[1..13] THEN BEGIN
                      GOTOXY(26,4+INT);
                      CASE INT OF
                      1:EDITLINE(AREAI.NAME,30);
                      2:EDITLINE(AREAI.FILENAME,12);
                      3:BEGIN
                        EDITLINE(AREAI.PATH,40);
                        IF AREAI.PATH[LENGTH(AREAI.PATH)]<>'\' THEN
                        AREAI.PATH:=AREAI.PATH+'\';
                        END;
                      4:EDITLINE(AREAI.PASSWORD,30);
                      5:EDITLINE(AREAI.ACS,30);
                      6:EDITLINE(AREAI.SPONSER,30);
                      7:BEGIN
                             S:=STRR(AREAI.MAXFILES);
                             EDITLINE(S,4);
                             AREAI.MAXFILES:=VALU(S);
                        END;
                      8:AREAI.FREE:=YESNO(AREAI.FREE);
                      9:BEGIN
                             S:=STRR(AREAI.POINTSK);
                             EDITLINE(S,4);
                             AREAI.POINTSK:=VALU(S);
                        END;
                      10:EDITLINE(AREAI.ULACS,30);
                      11:EDITLINE(AREAI.DLACS,30);
                      12:EDITLINE(AREAI.LISTACS,30);
                      13:AREAI.COMMISH:=YESNO(AREAI.COMMISH);
                      END;

                      SEEK(AREAF,FILEPOS(AREAF)-1);
                      WRITE(AREAF,AREAI);
                      END;
if int=14 then begin
                    seek(areaf,filesize(areaf));
                    areai.name:='=> New Area <=';
                    areai.filename:='NEW.DAT';
                    areai.path:='C:\';
                    areai.password:='';
                    areai.acs:='';
                    areai.sponser:='Judge Dredd';
                    areai.maxfiles:=9999;
                    areai.free:=false;
                    areai.pointsk:=10;
                    areai.ulacs:='';
                    areai.dlacs:='';
                    areai.listacs:='';
                    areai.commish:=false;
                    write(areaf,areai);
                    showinfo;

               end;

IF INT=15 THEN DELETEIT;
if int=16 then prevarea;
if int=17 then nextarea;
display;
showinfo;
until int=18;
END;

begin
Read_In_Config;
textattr:=7;
clrscr;
addarea;
end.
