uses dos,crt,tpansi,pullmode;
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 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
assign(t,'areaadd.ans');
reset(T);
repeat
read(t,c);
write(ansi,c);
until eof(t);
close(T);
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]:='N';

pm.ON[1] :='|B1|07Þ|B4|15A|B1|08Ý';
pm.ON[2] :='|B1|07Þ|B4|15B|B1|08Ý';
pm.ON[3] :='|B1|07Þ|B4|15C|B1|08Ý';
pm.ON[4] :='|B1|07Þ|B4|15D|B1|08Ý';
pm.ON[5] :='|B1|07Þ|B4|15E|B1|08Ý';
pm.ON[6] :='|B1|07Þ|B4|15F|B1|08Ý';
pm.ON[7] :='|B1|07Þ|B4|15G|B1|08Ý';
pm.ON[8] :='|B1|07Þ|B4|15H|B1|08Ý';
pm.ON[9] :='|B1|07Þ|B4|15I|B1|08Ý';
pm.ON[10]:='|B1|07Þ|B4|15J|B1|08Ý';
pm.ON[11]:='|B1|07Þ|B4|15K|B1|08Ý';
pm.ON[12]:='|B1|07Þ|B4|15L|B1|08Ý';
pm.ON[13]:='|B1|07Þ|B4|15M|B1|08Ý';
pm.ON[14]:='|B1|07Þ|B4|15!|B1|08Ý';
pm.ON[15]:='|B1|07Þ|B4|15@|B1|08Ý';
pm.ON[16]:='|B1|07Þ|B4|15[|B1|08Ý';
pm.ON[17]:='|B1|07Þ|B4|15]|B1|08Ý';
pm.ON[18]:='|B1|07Þ|B4|15N|B1|08Ý';

pm.OFF[1] :='|B0|07Þ|B4|15A|B0|08Ý';
pm.OFF[2] :='|B0|07Þ|B4|15B|B0|08Ý';
pm.OFF[3] :='|B0|07Þ|B4|15C|B0|08Ý';
pm.OFF[4] :='|B0|07Þ|B4|15D|B0|08Ý';
pm.OFF[5] :='|B0|07Þ|B4|15E|B0|08Ý';
pm.OFF[6] :='|B0|07Þ|B4|15F|B0|08Ý';
pm.OFF[7] :='|B0|07Þ|B4|15G|B0|08Ý';
pm.OFF[8] :='|B0|07Þ|B4|15H|B0|08Ý';
pm.OFF[9] :='|B0|07Þ|B4|15I|B0|08Ý';
pm.OFF[10]:='|B0|07Þ|B4|15J|B0|08Ý';
pm.OFF[11]:='|B0|07Þ|B4|15K|B0|08Ý';
pm.OFF[12]:='|B0|07Þ|B4|15L|B0|08Ý';
pm.OFF[13]:='|B0|07Þ|B4|15M|B0|08Ý';
pm.OFF[14]:='|B0|07Þ|B4|15!|B0|08Ý';
pm.OFF[15]:='|B0|07Þ|B4|15@|B0|08Ý';
pm.OFF[16]:='|B0|07Þ|B4|15[|B0|08Ý';
pm.OFF[17]:='|B0|07Þ|B4|15]|B0|08Ý';
pm.OFF[18]:='|B0|07Þ|B4|15N|B0|08Ý';

FOR X:=1 TO 18 DO BEGIN
                   PM.CX[X]:=2;
                   PM.CY[X]:=3+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);
                  clreol;
                  end;
textattr:=15;
gotoxy(18,4);
write(areai.name);
gotoxy(18,5);
write(areai.filename);
gotoxy(18,6);
write(areai.path);
gotoxy(18,7);
write(areai.password);
gotoxy(18,8);
write(areai.acs);
gotoxy(18,9);
write(areai.sponser);
gotoxy(18,10);
write(areai.maxfiles);
gotoxy(18,11);
write(areai.free);
gotoxy(18,12);
write(areai.pointsk);
gotoxy(18,13);
write(areai.ulacs);
gotoxy(18,14);
write(areai.dlacs);
gotoxy(18,15);
write(areai.listacs);
gotoxy(18,16);
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,'area.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(18,3+INT);
                      CASE INT OF
                      1:EDITLINE(AREAI.NAME,30);
                      2:EDITLINE(AREAI.FILENAME,12);
                      3:BEGIN
                        EDITLINE(AREAI.PATH,50);
                        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:='FART 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;
showinfo;
until int=18;
END;

begin
addarea;
end.
