PLEASE HELP ME WITH SEARCHING AND DELETING RECORDS

I am in the middle of writing a program for a friend who owns a newsagents in Turbo Pascal 7.  I have adapted a program I used in college but am now stuck because I don't know how to write a delete procedure to remove records that are no longer valid from the file member.dat  Also I am not sure how to search for records by using a members surname.  If anyone could help me it would be very much appreciated. The source code for my program is below. This is about the extent of my knowledge so if you could make it really simple to understand it would be a great help.

Thanks, John  



PROGRAM NEWSAGENTS;    
USES
    crt, printer, dos;

TYPE
    memberrec  = RECORD
      addrno   : BYTE;
      surname  : STRING[20];                  { Surname             }
      forename : STRING[15];                  { Forenames           }
      address  : ARRAY[1..4] OF STRING[30];   { Address             }
      postcode : STRING[8];                   { Post Code           }
      telno    : STRING[20];                  { Telephone Number    }
      dpapers  : STRING[50];                  { Mon-Sat Papers      }
      spapers  : STRING[50];                  { Sun Papers          }
      total    : REAL;                        { Total in GBP        }
      lpaid    : STRING[15];                  { Date Last Paid      }
    END;


VAR
   option      : CHAR;
   numberrec   : INTEGER;
   recnum      : INTEGER;
   IOcode      : INTEGER;
   recno       : INTEGER;
   infomem     : memberrec;
   tempfile    : FILE OF memberrec;
   rafilevar   : FILE OF memberrec;
   {$I NALIB.PAS}

FUNCTION getnomem : INTEGER;
BEGIN
     ASSIGN(rafilevar,'MEMBER.DAT');
     RESET(rafilevar);
     getnomem := FILESIZE(rafilevar);
     CLOSE(rafilevar);
END;    {*********** of function getnomem ***********}


PROCEDURE readmemrec (recno : INTEGER);
BEGIN
     {$I-}
     ASSIGN(rafilevar,'MEMBER.DAT');
     RESET(rafilevar);
     SEEK(rafilevar,recno);
     READ(rafilevar,infomem);
     CLOSE(rafilevar);
     {$I+}
END;    {************ of procedure readmemrec **********}

PROCEDURE press_next;
BEGIN
  cursors('C','N');
  TEXTCOLOR(15);
  GOTOXY(20,23); WRITELN('    Press Enter For Next Section...    ');
  READLN;
  cursors('C','S');
END;

PROCEDURE press_menu;
BEGIN
  cursors('C','N');
  TEXTCOLOR(15);
  GOTOXY(20,23); WRITELN('    Press Enter to Return to Menu...     ');
  READLN;
  cursors('C','S');
END;

PROCEDURE press_cont;
BEGIN
  cursors('C','N');
  TEXTCOLOR(15);
  GOTOXY(27,23);  WRITE('Press Enter to Continue...');
  READLN;
  cursors('C','S');
END;


{****************************************************************************
 THE FOLLOWING PROCEDURE WILL DISPLAY FULL DETAILS OF A MEMBER STORED IN THE
 DATABASE.
****************************************************************************}

PROCEDURE display_full_member_details;
VAR
   FF       : CHAR;
   ptr      : BYTE;
   recnum   : INTEGER;

BEGIN
  cursors('C','N');
  FF := #12;
  TEXTBACKGROUND(1);
  CLRSCR;
  TEXTCOLOR(15);
  GOTOXY(23,1);  WRITELN('HARTLEYS NEWS - CUSTOMER DETAILS');
  TEXTCOLOR(10);
  GOTOXY(15,5);  WRITELN('Surname            :- ');
  GOTOXY(15,6);  WRITELN('Forename           :- ');
  GOTOXY(15,8);
  WRITELN('Address  ');
  TEXTCOLOR(14);
    FOR ptr := 1 TO 4 DO WRITELN('                       ',infomem.address[ptr]);
  TEXTCOLOR(10);
  GOTOXY(15,14); WRITELN('Postcode           :- ');
  GOTOXY(15,15); WRITELN('Telephone Number   :- ');
  GOTOXY(15,16); WRITELN('Daily Papers       :- ');
  GOTOXY(15,17); WRITELN('Sunday Papers      :- ');
  GOTOXY(15,18); WRITELN('Total              :- ');
  TEXTCOLOR(14);
  GOTOXY(37,18); WRITELN('œ');
  TEXTCOLOR(10);
  GOTOXY(15,19); WRITELN('Last Paid          :- ');
  TEXTCOLOR(14);
  GOTOXY(37,5);  WRITE(infomem.surname);
  GOTOXY(37,6);  WRITE(infomem.forename);
  GOTOXY(37,14); WRITE(infomem.postcode);
  GOTOXY(37,15); WRITE(infomem.telno);
  GOTOXY(37,16);  WRITE(infomem.dpapers);
  GOTOXY(37,17); WRITE(infomem.spapers);
  GOTOXY(38,18); WRITE(infomem.total:2:2);
  GOTOXY(37,19); WRITE(infomem.lpaid);
  cursors('C','S');
END; {of PROCEDURE display_full_member_details}


{****************************************************************************
 THE FOLLOWING PROCEDURE WILL SEND FULL DETAILS OF A MEMBER STORED IN THE
 DATABASE TO THE PRINTER.
****************************************************************************}

PROCEDURE print_member_details;
VAR
  FF    : CHAR;
  reply : CHAR;
  ptr   : BYTE;

BEGIN
  FF := #12;
  TEXTCOLOR(15);
  GOTOXY(21,23); WRITE('Would You Like a Printout?  Y or N : ');
  READLN(reply);
  TEXTCOLOR(14);
   IF (reply='y') OR (reply='Y') THEN
     BEGIN
       GOTOXY(18,20);
       WRITELN('Sending Details to the Printer. Please Wait...');
       WRITELN(LST,'   Record Number = ',infomem.addrno);
       WRITELN(LST);
       WRITELN(LST,'     HARTLEYS NEWS - - CUSTOMER DETAILS');
       WRITELN(LST,'    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ');
       WRITELN(LST);
       WRITELN(LST,'      Surname          :- ',infomem.surname);
       WRITELN(LST,'      Forename         :- ',infomem.forename);
       WRITELN(LST);
       WRITELN(LST,'      Address  ');
         FOR ptr := 1 TO 4 DO WRITELN(LST,'                   ',infomem.address[ptr]);
       WRITELN(LST);
       WRITELN(LST,'      Postcode         :- ',infomem.postcode);
       WRITELN(LST,'      Telephone Number :- ',infomem.telno);
       WRITELN(LST,'      Daily Papers     :- ',infomem.dpapers);
       WRITELN(LST,'      Sunday Papers    :- ',infomem.spapers);
       WRITELN(LST,'      Total            :- ',infomem.total:2:2);
       WRITELN(LST,'      Last Paid        :- ',infomem.lpaid);
       WRITELN(LST,FF);
       GOTOXY(1,20); CLREOL;
     END;
END; {of PROCEDURE print_member_details}


{****************************************************************************
 THE FOLLOWING PROCEDURE CREATES THE FILE MEMBER.DAT
****************************************************************************}

PROCEDURE create_member_record;
VAR
   ptr : BYTE;

BEGIN
     CLRSCR;
     infomem.addrno := 0;
       FOR ptr := 1 TO 4 DO infomem.address[ptr] := 'A';
     infomem.surname  := 'A';
     infomem.forename := 'A';
     infomem.postcode := 'A';
     infomem.telno    := 'A';
     infomem.dpapers  := 'A';
     infomem.spapers  := 'A';
     infomem.total    :=  0 ;
     infomem.lpaid    := 'A';
     ASSIGN(rafilevar,'MEMBER.DAT');
     REWRITE(rafilevar);
     WRITE(rafilevar,infomem);
     CLOSE(rafilevar);
     WRITELN;
     WRITELN('PROCEDURE CREATE MEMBER RECORD WAS CALLED BY MAIN MENU');
     READLN;
END; {of PROCEDURE create_member_record}


{****************************************************************************
 THE FOLLOWING PROCEDURE DISPLAYS THE PROMPTS ON THE ADD_MEMBER SCREEN
****************************************************************************}

PROCEDURE disp_mem;
BEGIN
  TEXTCOLOR(10);
  GOTOXY(5,5);   WRITE('Surname                   : ');
  GOTOXY(5,6);   WRITE('Forename                  : ');
  GOTOXY(5,8);   WRITELN('Address (4 lines)');
  GOTOXY(5,14);  WRITE('Postcode                  : ');
  GOTOXY(5,15);  WRITE('Telephone Number          : ');
  GOTOXY(5,16);  WRITE('Daily Papers              : ');
  GOTOXY(5,17);  WRITE('Sunday Papers             : ');
  GOTOXY(5,18);  WRITE('Total                     : ');
  TEXTCOLOR(14);
  GOTOXY(33,18); WRITE('œ');
  TEXTCOLOR(10);
  GOTOXY(5,19);  WRITE('Last Paid                 : ');
END; {of PROCEDURE disp_mem}


{****************************************************************************
 THE FOLLOWING PROCEDURE GATHERS THE INFO ON THE ADD_MEMBER SCREEN
****************************************************************************}

PROCEDURE read_mem;
VAR
  ptr : BYTE;

BEGIN
  TEXTCOLOR(14);
  GOTOXY(33,5);  READLN(infomem.surname);
  GOTOXY(33,6);  READLN(infomem.forename);
  GOTOXY(1,9);   FOR ptr := 1 TO 4 DO READLN(infomem.address[ptr]);
  GOTOXY(33,14); READLN(infomem.postcode);
  GOTOXY(33,15); READLN(infomem.telno);
  GOTOXY(33,16); READLN(infomem.dpapers);
  GOTOXY(33,17); READLN(infomem.spapers);
  REPEAT
  {$I-}
  TEXTCOLOR(14);
  GOTOXY(34,18); READLN(infomem.total);
  {$I+}
  IOcode:=IOresult;
  IF IOcode <> 0 THEN
     BEGIN
       TEXTCOLOR(15);
       GOTOXY(20,23); WRITELN('INVALID DATA, PLEASE RE-ENTER');
       DELAY(1000);
       GOTOXY(20,23); WRITELN('                                   ');
       GOTOXY(34,18); CLREOL;
     END;
  UNTIL IOcode = 0;
  GOTOXY(33,19); READLN(infomem.lpaid);
END; {of PROCEDURE read_mem}


{****************************************************************************
 THE FOLLOWING PROCEDURE ADDS A MEMBER TO THE DATABASE
****************************************************************************}

PROCEDURE add_member;
VAR
  response  : CHAR;

BEGIN
  CLRSCR;
      REPEAT
        TEXTBACKGROUND(1);
        CLRSCR;
        numberrec := getnomem;
        TEXTCOLOR(15);
        GOTOXY(21,1);  WRITELN('HARTLEYS NEWS - ADD NEW CUSTOMER');
        disp_mem;
        read_mem;
        press_next;
        infomem.addrno := numberrec;
        ASSIGN(rafilevar,'MEMBER.DAT');
        RESET(rafilevar);
        SEEK(rafilevar,numberrec);
        WRITE(rafilevar,infomem);
        CLOSE(rafilevar);
        display_full_member_details;
        print_member_details;
        CLRSCR;
        TEXTCOLOR(14);
        GOTOXY(15,10);
        WRITE('Would You Like to Enter Another Record. Y or N : ');
        READLN(response);
      UNTIL (response='n') OR (response='N');
END; {of PROCEDURE add_member}


{****************************************************************************
 THE FOLLOWING TWO PROCEDURES DISLAY THE PROMPTS FOR MODIFYING A RECORD
****************************************************************************}

PROCEDURE member_headings;
BEGIN
  TEXTCOLOR(15);
  GOTOXY(5,5);   WRITE('A -  ');
  GOTOXY(5,6);   WRITE('B -  ');
  GOTOXY(5,7);   WRITELN('C -  ');
  GOTOXY(5,8);   WRITE('D -  ');
  GOTOXY(5,15);  WRITE('E -  ');
  GOTOXY(5,16);  WRITE('F -  ');
  GOTOXY(5,17);  WRITE('G -  ');
  GOTOXY(5,18);  WRITE('H -  ');
  GOTOXY(5,19);  WRITE('I -  ');
END; {of PROCEDURE member_headings}

PROCEDURE disp_member_prompts;
BEGIN
  TEXTCOLOR(10);
  GOTOXY(10,5);   WRITE('Surname                  ');
  GOTOXY(10,6);   WRITE('Forename                 ');
  GOTOXY(10,8);   WRITELN('Address (4 lines)      ');
  GOTOXY(10,14);  WRITE('Post Code                ');
  GOTOXY(10,15);  WRITE('Telephone Number         ');
  GOTOXY(10,16);  WRITE('Daily Papers             ');
  GOTOXY(10,17);  WRITE('Sunday Papers            ');
  GOTOXY(10,18);  WRITE('Total                    ');
  GOTOXY(10,19);  WRITE('Last Paid                ');
END; {of PROCEDURE disp_member_prompts}


{****************************************************************************
 THE FOLLOWING THREE PROCEDURES GATHER NEW INFORMATION AND UPDATE THE
 RECORD.
****************************************************************************}

PROCEDURE field;
BEGIN
  TEXTCOLOR(15);
  GOTOXY(14,23);
  WRITE('Please Enter the Field to be Modified (X to Quit) : ');
END; {of PROCEDURE field}

PROCEDURE modify_member_rec;
VAR
  fieldno : CHAR;
  ptr     : BYTE;

BEGIN
  field;
  REPEAT
    GOTOXY(66,23); WRITE('      ');
    GOTOXY(66,23);
    READLN(fieldno);
    TEXTCOLOR(14);
    WITH infomem DO
      BEGIN
        CASE fieldno OF

          'A','a' : BEGIN
                      GOTOXY(37,5);  CLREOL;
                      GOTOXY(37,5);  READLN(surname);
                    END;
          'B','b' : BEGIN
                      GOTOXY(37,6);  CLREOL;
                      GOTOXY(37,6);  READLN(forename);
                    END;
          'C','c' : BEGIN
                      GOTOXY(20,9);  CLREOL;
                      GOTOXY(20,10); CLREOL;
                      GOTOXY(20,11); CLREOL;
                      GOTOXY(20,12); CLREOL;
                      GOTOXY(1,9);   FOR ptr := 1 TO 4 DO READLN(infomem.address[ptr]);
                    END;
          'D','d' : BEGIN
                      GOTOXY(37,14); CLREOL;
                      GOTOXY(37,14); READLN(postcode);
                    END;
          'E','e' : BEGIN
                      GOTOXY(37,15); CLREOL;
                      GOTOXY(37,15); READLN(telno);
                    END;
          'F','f' : BEGIN
                      GOTOXY(37,16); CLREOL;
                      GOTOXY(37,16); READLN(dpapers);
                    END;
          'G','g' : BEGIN
                      GOTOXY(37,17); CLREOL;
                      GOTOXY(37,17); READLN(spapers);
                    END;
          'H','h' : BEGIN
                      GOTOXY(38,18); CLREOL;
                      REPEAT
                      {$I-}
                      TEXTCOLOR(14);
                      GOTOXY(38,18); CLREOL;
                      GOTOXY(38,18); READLN(total);
                      {$I+}
                      IOcode:=IOresult;
                      IF IOcode <> 0 THEN
                         BEGIN
                           TEXTCOLOR(15);
                           GOTOXY(26,21); WRITELN('INVALID DATA, PLEASE RE-ENTER');
                           DELAY(1000);
                           GOTOXY(26,21); WRITELN('                                   ');
                         END;
                      UNTIL IOcode = 0;
                    END;
          'I','i' : BEGIN
                      GOTOXY(37,19); CLREOL;
                      GOTOXY(37,19); READLN(lpaid);
                    END;
          'X','x' : BEGIN
                      GOTOXY(1,23);
                      CLREOL;
                      GOTOXY(25,23);
                    END
                  ELSE
                    BEGIN
                      cursors('C','N');
                      TEXTCOLOR(15);
                      GOTOXY(1,23);
                      CLREOL;
                      GOTOXY(23,23);
                      WRITE('Enter A - I Only.  Please Wait...');
                      DELAY(2000);
                      cursors('C','S');
                      field;
                    END;
        END;
    END;
  UNTIL (fieldno = 'X') OR (fieldno = 'x');
END; {of PROCEDURE modify_member_rec}

PROCEDURE modify;
VAR
  reply : CHAR;

BEGIN
  CLRSCR;
  begin
    REPEAT
          REPEAT
            numberrec := getnomem;
            CLRSCR;
            intro_box(4,1,14);
            GOTOXY(15,21);WRITE('                                         ');
            GOTOXY(21,5); WRITELN('HARTLEYS NEWS - MODIFY CUSTOMER DETAILS');
            GOTOXY(20,6); WRITELN('ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ');
            GOTOXY(23,11);  WRITE('Customer record number := ');
            {$I-}
            READLN(recnum);
            {$I+}
            IOcode:=IOresult;
              IF IOcode <> 0 THEN
                BEGIN
                  TEXTCOLOR(15);
                  GOTOXY(26,19); WRITELN('INVALID DATA, PLEASE RE-ENTER');
                  DELAY(1000);
                END;
          UNTIL IOcode = 0;
        UNTIL (recnum <= getnomem) and (recnum > 0);
        readmemrec(recnum);
        display_full_member_details;
        member_headings;
        disp_member_prompts;
        modify_member_rec;
        display_full_member_details;
        print_member_details;
        infomem.addrno := getnomem;
        ASSIGN(rafilevar,'MEMBER.DAT');
        RESET(rafilevar);
        SEEK(rafilevar,recnum);
        WRITE(rafilevar,infomem);
        CLOSE(rafilevar);
      END;
END; {of PROCEDURE modify}


{****************************************************************************
 THE FOLLOWING PROCEDURE ASKS WHICH FULL RECORD OF A CUSTOMER YOU WANT TO
 DISPLAY AND CALLS THE PROCEDURE display_full_member_details
****************************************************************************}

PROCEDURE Display_Max;
BEGIN
REPEAT
REPEAT
  infomem.addrno := 0;
  CLRSCR;
  intro_box(4,1,14);
  GOTOXY(15,21);WRITE('                                         ');
  GOTOXY(21,5); WRITELN('HARTLEYS NEWS - FULL CUSTOMER DETAILS');
  GOTOXY(20,6); WRITELN('ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ');
  GOTOXY(14,9); WRITELN('There is ',getnomem-1,' record(s).');
  GOTOXY(14,11);WRITE('Which record do you want to view? Record Number :- ');
  {$I-}
  READLN(recnum);
  {$I+}
  IOcode:=IOresult;
  IF IOcode <> 0 THEN
     BEGIN
       TEXTCOLOR(15);
       GOTOXY(26,19); WRITELN('INVALID DATA, PLEASE RE-ENTER');
       DELAY(2000);
     END;
  IF (recnum>getnomem-1) and (recnum<getnomem-1) THEN
     BEGIN
       GOTOXY(26,21); WRITELN('INVALID DATA, PLEASE RE-ENTER');
       DELAY(2000);
     END;
UNTIL (recnum <= getnomem) and (recnum > 0);
UNTIL IOcode = 0;
  CLRSCR;
  GOTOXY(1,5);
  readmemrec(recnum);
  display_full_member_details;
  press_menu;
END;  {of PROCEDURE Display_Max}


{****************************************************************************
 THE FOLLOWING PROCEDURE DISPLAYS THE TABLE THAT IS SHOWN ON THE DISPLAY
 BRIEF RECORDS SCREEN
****************************************************************************}

PROCEDURE brief_box;
BEGIN
  TEXTCOLOR(14);
  GOTOXY(2,5);
  WRITELN('ÉÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
  GOTOXY(2,6);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,7);
  WRITELN('ÌÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÎÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹');
  GOTOXY(2,8);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,9);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,10);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,11);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,12);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,13);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,14);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,15);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,16);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,17);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,18);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,19);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,20);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,21);
  WRITELN('º        º                    º                    º                         º');
  GOTOXY(2,22);
  WRITELN('ÈÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ')
END; {of PROCEDURE brief_box}

PROCEDURE min_members(X,Y   :BYTE;
                      recno : INTEGER);
BEGIN
{$I-}
  GOTOXY(X,Y);    WRITE(recno);
  GOTOXY(X+9,Y);  WRITE(infomem.surname);
  GOTOXY(X+30,Y); WRITE(infomem.forename);
  GOTOXY(X+51,Y); WRITE(infomem.telno);
{$I+}
END;{of PROCEDURE DisplayMinRecord}

PROCEDURE Display_Min;
VAR
   startrecord   : INTEGER;
   endrecord     : INTEGER;
   pageno        : BYTE;
   pagerecordno  : BYTE;
   X,Y           : BYTE;
   option        : CHAR;

BEGIN
REPEAT
          REPEAT
          infomem.addrno := 0;
          CLRSCR;
          intro_box(4,1,14);
          GOTOXY(15,21);WRITE('                                         ');
          GOTOXY(21,5); WRITELN('HARTLEYS NEWS - BRIEF CUSTOMER DETAILS');
          GOTOXY(20,6); WRITELN('ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ');
            GOTOXY(18,9);
            WRITELN('There is ',getnomem-1,' Member(s) Held in the Database');
            GOTOXY(15,11);  WRITELN('Hence You can Display any Group of Members in the');
            GOTOXY(15,12);  WRITELN('Range 1 to ',getnomem-1,'.');
            {$I-}
            GOTOXY(18,15); WRITE('Start the display at record number  :- ');
            READLN(startrecord);
            GOTOXY(18,17); WRITE('End the display at record number    :- ');
            READLN(endrecord);
            {$I+}
            IOcode:=IOresult;
              IF IOcode <> 0 THEN
                BEGIN
                  cursors('C','N');
                  TEXTCOLOR(15);
                  GOTOXY(26,19);  WRITELN('INVALID DATA, PLEASE RE-ENTER');
                  DELAY(1000);
                  cursors('C','S');
                END;
              IF (startrecord<1) OR (startrecord>getnomem-1) OR (endrecord<0) OR (endrecord>getnomem-1) THEN
                BEGIN
                  TEXTCOLOR(15);
                  cursors('C','N');
                  GOTOXY(26,19);  WRITELN('INVALID DATA, PLEASE RE-ENTER');
                  DELAY(1000);
                  cursors('C','S');
                END;
          UNTIL (startrecord>0) AND (startrecord<=getnomem-1) AND (endrecord>0) AND (endrecord<=getnomem-1);
        UNTIL IOcode = 0;
        cursors('C','N');
        GOTOXY(24,21); WRITE('Press Enter to View Next Page...');
        READLN;
        cursors('C','S');
        pageno := 0;
        startrecord := startrecord;
        endrecord := endrecord;
          WHILE startrecord <= endrecord DO
            BEGIN
              INC(pageno);
              CLRSCR;
              brief_box;
              TEXTCOLOR(15);
              GOTOXY(15,2); WRITELN('HARTLEYS NEWS - BRIEF CUSTOMER DETAILS  PAGE No.',PageNo);
              GOTOXY(14,3); WRITELN('ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ');
              TEXTCOLOR(10);
              GOTOXY(4,6);
              WRITE('Record');
              GOTOXY(18,6);
              WRITE('Surname');
              GOTOXY(39,6);
              WRITE('Forename');
              GOTOXY(60,6);
              WRITE('Telephone No.');
              TEXTCOLOR(14);
              X := 4; Y := 8;
              pagerecordno := 1;
                WHILE (pagerecordno <= 14) AND (startrecord <= endrecord) DO
                  BEGIN
                    readmemrec(startrecord);
                    min_members(X,Y,startrecord);
                    INC(pagerecordno);
                    INC(Y);
                    INC(startrecord);
                  END;
              GOTOXY(1,23);
              CLREOL;
              press_cont;
            END;

END;  {of PROCEDURE Display Minimum data}


{****************************************************************************
 THE FOLLOWING PROCEDURE DISPLAYS THE MAIN MENU
****************************************************************************}

PROCEDURE menu;
BEGIN
  REPEAT
    CLRSCR;
    intro_box(4,1,14);
    GOTOXY(26,5);   WRITELN('HARTLEYS NEWS - MAIN MENU');
    GOTOXY(25,6);   WRITELN('ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ');
    GOTOXY(26,9);   WRITELN('A  -   Add New Customer');
    GOTOXY(26,10);  WRITELN('B  -   Modify a Record');
    GOTOXY(26,11);  WRITELN('C  -   Delete a Record');
    GOTOXY(26,12);  WRITELN('D  -   Display Full Details');
    GOTOXY(26,13);  WRITELN('E  -   Display Brief Details');
    GOTOXY(26,14);  WRITELN('F  -   Search by Surname');
    GOTOXY(26,15);  WRITELN('G  -   Quit This Program');
    GOTOXY(25,21);  WRITE('  Choose A - G. Your Choice = ');
    READLN(option);
    CASE option OF
      'Z','z' : create_member_record;
      'A','a' : add_member;
      'B','b' : modify;
      {'C','c' : delete_members;}
      'D','d' : display_max;
      'E','e' : display_min;
      {'F','f' : search;}
      'G','g' : quit;
    ELSE
      cursors('C','N');
      TEXTCOLOR(lightgreen);
      TEXTBACKGROUND(0);
      GOTOXY(20,23);
      WRITE('ERROR - ENTER A - G ONLY.');
      DELAY(2000);
      cursors('C','S');
    END;
  UNTIL option IN['G','g'];
END; {of PROCEDURE Menu}



BEGIN
  highvideo;
  menu;
END.



*****************************************************

THE FOLLOWING IS THE LIBRARY FILE {$I NALIB.PAS}

*****************************************************

{NALIB.PAS}

PROCEDURE The_Date;
VAR
   year, month, day, dweek : WORD;

BEGIN
     GETDATE(year,month,day,dweek);
     WRITE(day,'/',month,'/',year);
END;


PROCEDURE The_Time;
VAR
   hour, minute, second, sec : WORD;

BEGIN
     REPEAT
     GETTIME(hour,minute,second,sec);
     GOTOXY(44,12);
     WRITE(hour,':',minute:2,':',second:2);
     DELAY(1000);
     UNTIL keypressed;
END;

PROCEDURE Intro_box(back,box,text : BYTE); {Pass 3 parameters for colours}

{black=0, blue=1, green=2, cyan=3, red=4, magenta=5, brown=6, lightgray=7
 darkgray=8, lightblue=9, lightgreen=10, lightcyan=11, lightred=12,
 lightmagenta=13, yellow=14, white=15}

VAR
  I  : INTEGER; {I=loop counter and GOTOXY position}

BEGIN
     TEXTBACKGROUND(back);   {colour for back of screen around box}
     CLRSCR;                 {fill whole screen with this colour}
     TEXTBACKGROUND(box);    {colour of inside of box}
     TEXTCOLOR(text);        {foreground colour of text inside box}
     GOTOXY(10,4);           {top of box}
     WRITE('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
     {loop to display sides of the box}
     FOR I:=5 TO 21 DO   {lines 5 to 21 are sides of the box}
        BEGIN
        GOTOXY(10,I);
        WRITE('º                                                           º');
        END;
     {bottom of box}
     GOTOXY(10,22);
     WRITE('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
     {change foreground colour to black for shadow around box}
     TEXTCOLOR(black);
     FOR I:=5 TO 22 DO   {black shadow to right of box - lines 5 to 22}
        BEGIN
        GOTOXY(71,I);
        WRITE('Û');      {alt 219 - solid square of black shadow}
        END;
     FOR I:=11 TO 71 DO  {black shadow underneath box - columns 11 to 71}
        BEGIN
        GOTOXY(I,23);
        WRITE('Û');
        END;
     {go back to previous foreground colour passed to procedure}
     TEXTCOLOR(text);
     GOTOXY(33,5);
     WRITE('INTRODUCTION');  {heading}
     GOTOXY(33,6);
     WRITE('ÄÄÄÄÄÄÄÄÄÄÄÄ');  {ALT 196 - to underline heading}
     GOTOXY(25,21);
     WRITE('Press any key to continue...');
END;                          {END of Procedure Intro_box}


PROCEDURE cursors(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
    'N' : BEGIN
            regs.CH := $20;
            regs.CL := $20;
          END;
    'S' : BEGIN
            regs.CH := $6+I;
            regs.CL := $7+I;
          END;
    'L' : BEGIN
            regs.CH := $0;
            regs.CL := $7+I;
          END;
    END;
    intr($10, regs);
END;


PROCEDURE Reset_Screen;
BEGIN
     TEXTCOLOR(white);
     TEXTBACKGROUND(black);
     CLRSCR;
END;


PROCEDURE quit;
BEGIN
     cursors('C','N');
     CLRSCR;
     GOTOXY(24,10);
     WRITELN('Thank You For Using This Program');
     READKEY;
     reset_screen;
     cursors('C','S');
END;


PROCEDURE passwrd;
CONST
   correct = 'FUTURE';

VAR
  password : ARRAY[1..9] OF CHAR;   {9 character array for password entered}
  I, J     : INTEGER;               {loop & line counters}
  ascii    : INTEGER;               {ascii code of characters entered}

BEGIN
  REPEAT
   TEXTBACKGROUND(blue);
   TEXTCOLOR(lightgreen);
   CLRSCR;                          {clear to blue on white}
   GOTOXY(27,8);
   WRITELN('Enter password below:');{data entry box}
   GOTOXY(23,9);  WRITELN('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
   GOTOXY(23,10); WRITELN('º                            º');
   GOTOXY(23,11); WRITELN('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
   J:=27;                           {start position 27 on line inside box}
   I:=1;                            {first element of array password}
   REPEAT                           {loop to get each character}
      GOTOXY(J,10);                 {position cursor on line 10}
      password[I] := READKEY;       {read next character in to array}
      GOTOXY(J,10);  WRITE('*');    {overwrite with an *, at same place}
      ascii := ORD(password[I]);    {get ascii code of character}
      INC(J);                       {move one position along line 10}
      INC(I);                       {move one position along character array}
   UNTIL ascii = 13;                {ascii 13 is ENTER key so pasword entered}

   UNTIL password = correct;
   GOTOXY(25,15);
   TEXTCOLOR(14);                  {change to red for accept/reject message}

   IF password = correct THEN       {check to see if required password}
      WRITELN('Password accepted')
   ELSE
      WRITELN('INCORRECT. Password rejected ');
   GOTOXY(23,24);
   TEXTCOLOR(blue);                 {reset colour to blue}
   WRITE('Press any key to continue....');
   READKEY;                         {get key press to end}
END;


LVL 14
john-formbyAsked:
Who is Participating?
 
3lerConnect With a Mentor Commented:
ok i sent you an email with the solution for searching..
0
 
3lerCommented:
well you can't really delete a record but u can add a FREE:boolean; property in the record and if the record is full/occupied you set it FALSE if you delete it you set it TRUE.
When you insert into a file you simply find the first record with the EMPTY property set to TRUE. U get a dense file that way...

Searching is easy. You make a loop. You read records until you find the one with the surname you were looking for.

ex.

while NOT eof(file) do
 begin
  (*read from file;compare;...*)
 end.
0
 
dbruntonCommented:
Well, read this link

http://www.experts-exchange.com/Programming/Programming_Languages/Pascal/Q_20465314.html

And find whatboy's postings (ignore his use of language).  He'll show methods of deleting records if you want to use them.  And there's other info there as well if you don't go that way.

And the comments by 3ler on marking a record full or occupied are the recommended method.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
john-formbyAuthor Commented:
OK I am really not very good at pascal programming. I gave the search thing a go but I can't get it to work. Here is my code.


PROCEDURE search;
VAR
  sname   : STRING;
  nomatch : BOOLEAN;

BEGIN
  CLRSCR;
  infomem.addrno := 1;
  ASSIGN(rafilevar,'MEMBER.DAT');
  RESET(rafilevar);
  GOTOXY(1,5);  WRITE('Enter Surname : ');
  GOTOXY(17,5); READLN(sname);
  nomatch:=TRUE;
  WHILE NOT EOF (rafilevar) DO
    BEGIN
      READ(rafilevar,infomem);
      IF (sname=infomem.surname) THEN
      BEGIN
      CLRSCR;
      writeln(recno);
      WRITELN('Surname : ',infomem.surname);
      WRITELN('Forename: ',infomem.forename);
      READLN;
      nomatch:=FALSE;
      END;
      CLOSE(rafilevar);
      IF nomatch THEN
      BEGIN
        WRITELN('NO MATCH FOUND');
        READKEY;
      END;
    END;
END;


I am also no closer to understanding how to delete records either.  I am in desparate need of a solution. I have tried reading books and searching on the internet but I don't have a clue how to code what I need.  If anyone can give me a complete answer I would be very very happy.
 
0
 
3lerCommented:
ok this i good and it should do the job
-u might want to use a local variable to read into and compare from...
-and that readkey there can (i'd do it) be replaced with a readln;
-define the sname string as sname:string[20] like in the record ;)
-oh and last but not least.. this doesnt work if the file does no exist..
try:
{-I}
reset(file);
if IOResult = 0 then (*do the program*)
else
writeln('file not found');
{+I}

in case you are wondering... that {+-I} is a compiler instruction that disables (-) and enables (+) IO errors.. the prog does not crash when an IO error ocurs if its disabled.

hope i helped..
post on you progres---
 
0
 
john-formbyAuthor Commented:
Sorry but I am still stuck.  Is it possible for someone to write the code I need cause I have been stuck on this for about 2 weeks in total and I am not getting anywhere. The above code I wrote for searching doesn't work, it just crashes, even when I enter a name that is in the file member.dat I need to be able to search by Surname and to be able to delete records that are no longer in use.  Please can someone help me out. I really don't know where to begin. Even the comments that have been left for me so far (for which I am very grateful that you have taken the time to try and help) have lost me. Before I started doing this for a friend it was about 3 years since I did anything in Pascal. If it is possible I will award extra points or anything. I don't want my friend to think I can't do this cause I promised him.

If anyone wants to help I can e-mail the files to them to make it easier. Just let me know

Thanks, john-formby
0
 
john-formbyAuthor Commented:
Sorry but I am still stuck.  Is it possible for someone to write the code I need cause I have been stuck on this for about 2 weeks in total and I am not getting anywhere. The above code I wrote for searching doesn't work, it just crashes, even when I enter a name that is in the file member.dat I need to be able to search by Surname and to be able to delete records that are no longer in use.  Please can someone help me out. I really don't know where to begin. Even the comments that have been left for me so far (for which I am very grateful that you have taken the time to try and help) have lost me. Before I started doing this for a friend it was about 3 years since I did anything in Pascal. If it is possible I will award extra points or anything. I don't want my friend to think I can't do this cause I promised him.

If anyone wants to help I can e-mail the files to them to make it easier. Just let me know

Thanks, john-formby
0
 
3lerCommented:
ok john .. did you change the stuff i mentioned above?

oh and plz send me the files: 3ler@mreza.info
i'd answer now but it's 22:43 where i'm from ;)
i'll post tomorow

--3ler
0
 
john-formbyAuthor Commented:
I tried to send you an email from yahoo mail to the address above with the files attached but it said failed delivery.
0
 
3lerCommented:
ok try triler@email.si
the above is workin but i guess yahoo does not like private servers.. : )

ok going to bed now :)

0
 
john-formbyAuthor Commented:
I have sent the files to the above address. I tried to send an executable but it wouldn't let me so you just have the .pas files

John-formby
0
All Courses

From novice to tech pro — start learning today.