I Need Some Help With A Program I Am Making I Have Created 2 Program One To Create The File And The Main Program. But There Is One Problem When Ever More Data Is Added To The End Of The File It Copy's The First Lot Of Data And Starts Overwriting.
Example: I Store The A Name (intel1111) Then Try To Store Another (intel2) It Will Do This To The Record intel1111 intel2111 <-- Keeps The Last Set Of Data. I Hope You Understand Because Its Difficult To Explain.

program NewUser;
uses sysutils, crt;

type
      UserInfo = record
                     UserName : string [20];
                     DOB : integer;
                     Password : string;
                     Forename : string [25];
                     Surname : string [30];
                     Regular : char;
                     Miles : integer;
                     Cold : char;
                     Large : char;
                     Small : char;
                     PubMiles : real;
                     PubTot: real;
                     Hours : integer;
                     PlaneTot : integer;
                     Total : real;
                     SubTotal : real;
                     UserNum : integer;
                  end;

var
   CarMile : integer;
   User : UserInfo;
   UserFile : file of UserInfo;
   MenuChoice, Correct, PubCorrect, ModChoice : char;
   ColdNum, LargeNum, SmallNum : real;
   Username , Password , PassCheck : String;
   UserFound, PassFound : Boolean;


procedure NewUser1;
   begin
      reset(UserFile);
      seek(UserFile, filesize (UserFile));
      writeln;
      writeln;
      textcolor (Cyan);
      writeln ('Input User Information');
      writeln ('======================');
      writeln;
      textcolor (Red);
      writeln ('Please Enter Your Surname');
      readln (User.Surname);
      textcolor (Cyan);
      writeln ('Please Enter Your Forename');
      readln (User.Forename);
      textcolor (Red);
      writeln ('Please Enter Your Date Of Birth In Format DDMMYY');
      readln (User.DOB);
      textcolor (Cyan);
      writeln ('Please Enter Your Desired Username');
      readln (User.Username);
      repeat
         textcolor (Red);
         writeln ('Please Enter A Password');
         readln (User.Password);
         textcolor (Cyan);
         writeln ('Please Confirm Your Password');
         readln (PassCheck);
         if PassCheck <> User.Password then
            textbackground (White);
            textcolor (Black);
            writeln ('The Passwords Did Not Match Please Try Again');
            textbackground (Black);
      until PassCheck = User.Password;
               User.UserNum := User.UserNum + 1;
               write (UserFile, User);
               close (UserFile);
               textcolor (Yellow);
               writeln ('Your User Login Has Been Created');
               writeln ('Press Enter To Go Back To The Main Menu');
               readln;
      end;

procedure CreateUser;
begin
NewUser1;
end;


procedure Login;
   begin
      repeat

      reset (UserFile);
      textbackground (Yellow);
      textcolor (Blue);
      writeln ('Please Enter Your Username');
      readln (Username);
         read (UserFile, User);
            if User.UserName = Username then

               begin
                  UserFound := true;
                  textbackground (Blue);
                  textcolor (Yellow);
                  writeln ('User Found');
                  textbackground (Yellow);
                  textcolor (Blue);
                  writeln ('Hello ',User.Forename,' ',User.Surname);
               end
            else
               begin
                 textbackground (White);
                 textcolor (Black);
                 writeln ('wError - No Such User');
                 writeln ('Please Try Again');
               end;
   until (UserFound);
   end;

   procedure PasswordLog;

      begin
      repeat
      reset (UserFile);
      textbackground (Yellow);
      textcolor (Blue);
      writeln ('Please Enter Your Password');
      readln (Password);
      read (UserFile, User);
            if User.Password = Password then
               begin
                  PassFound := true;
                  textbackground (Blue);
                  textcolor (Yellow);
                  writeln ('Password Correct');
               end
            else
               begin
         textbackground (White);
         textcolor (Black);
         writeln ('Error - Password Incorrect');
         writeln ('Please Try Again');
               end;
   until (PassFound);
   end;
               procedure ExtraInfo;
               begin
               writeln;
               writeln ('Are Most Your Journeys Under 3 Miles? (Y/N)');
               User.Cold := readkey;
               writeln ('Is Your Car Engine Over 1.6 Litres? (Y/N)');
               User.Large := readkey;
                  if upcase (User.Large) = 'N' then
                     begin
                        writeln ('Is Your Car Engine Under 1.4 Litres? (Y/N)');
                        User.Small := readkey;
                     end;
   end;

   procedure Obtain;
   begin

      repeat

      repeat
         begin

            writeln ('Estimate How Many Miles You Travel In A Year');
            readln (User.Miles);
         end;
            if (User.Miles >= 263000) or (User.Miles <=0) then
               begin
                  writeln ('This Figure Too High');
                  writeln ('Please Try Again');
               end;
      until (User.Miles < 263000) and (User.Miles >0);
         writeln;
         writeln ('You Roughly Travel ',User.Miles,' Miles A Year');
         writeln ('Is This Correct? (Y/N)');
         Correct := readkey;

      until upcase (Correct) = 'Y';
      if upcase (User.Regular) = 'Y' then ExtraInfo;
      end;


procedure RegDriver;
   begin
      User.Miles := 0;
      writeln ('Are You A Regular Car User? (Y/N)');
      User.Regular := readkey;
   end;

procedure Test;
   begin
      if upcase (User.Regular) = 'Y' then Obtain;
   end;

procedure LowMileage;
   begin
      User.SubTotal := User.SubTotal + 2075;
      writeln ('You Are A Low Mileage Driver');
   end;

procedure TypicalDriver;
   begin
      User.SubTotal := User.SubTotal + 4150;
      writeln ('You Are A Typical Driver');
   end;

procedure HighMileage;
   begin
      User.SubTotal := User.SubTotal + 6200;
      writeln ('You Are A High Mileage Driver');
   end;

procedure VeryHighMileage;
   begin
      User.SubTotal := User.SubTotal + 8300;
      writeln ('You Are A Very High Mileage Driver');
   end;

procedure ColdCal;
   begin
      ColdNum := User.SubTotal / 4;
      User.SubTotal := User.SubTotal + ColdNum;
   end;

procedure LargeCal;
   begin
      LargeNum := User.SubTotal / 2;
      User.SubTotal := User.SubTotal + LargeNum;

   end;

procedure SmallCal;
   begin
      SmallNum := User.SubTotal / 3;
      User.SubTotal := User.SubTotal - SmallNum;

   end;

procedure Pub;
   begin
      repeat
         writeln;
         writeln ('Estimate How Many Miles You Travel Weekly On Public Transport');
         readln (User.PubMiles);
         writeln ('You Have Entered ',User.PubMiles:4:2,' Miles Weekly Is This Correct (Y/N)');
         PubCorrect := readkey;
            if upcase (PubCorrect) = 'N' then
               writeln ('Please Re-Enter');
      until upcase (PubCorrect) = 'Y';
      User.PubTot := (700 / 150) * User.PubMiles;
   end;

procedure Flying;
   begin
      writeln;
      writeln ('Estimate How Many Hours You Spent Flying Last Year');
      readln (User.Hours);
      User.PlaneTot := User.Hours * 350;
   end;

procedure Calculate;
   begin
      User.Total := 0;
      User.SubTotal := 0;
      if (upcase (User.Regular) = 'Y') and (User.Miles <= 5000) and (User.Miles >0) then LowMileage;
      if (upcase (User.Regular) = 'Y') and (User.Miles <= 10000) and (User.Miles >= 5000) then TypicalDriver;
      if (upcase (User.Regular) = 'Y') and (User.Miles <= 15000) and (User.Miles >= 10000) then HighMileage;
      if (upcase (User.Regular) = 'Y') and (User.Miles > 15000) then VeryHighMileage;
      if upcase (User.Cold) = 'Y' then ColdCal;
      if upcase (User.Large) = 'Y' then LargeCal;
      if upcase (User.Small) = 'Y' then SmallCal;
      User.Total := User.SubTotal + User.PubTot;
      User.Total := User.PlaneTot + User.Total;
      writeln;
      textcolor (Yellow);
      writeln ('Your Annual Transport Score Is ',User.Total:4:2);
      write (UserFile, User);
   end;

procedure Display;
   begin
      writeln;
      textcolor (Yellow);
      with User do
         begin

            writeln ('Your Estimated Annual Mileage Is ',Miles);
            if upcase (Large) = 'Y' then

                  writeln ('You Drive A Large Car (Over 1.6 Litres)')
            else
                  if upcase (Small) = 'Y' then
                     writeln ('You Drive A Small Car (Under 1.4 Litres')
                  else
                     writeln ('You Drive A Regular Car (1.4 Or 1.6 Litres)');

            writeln ('This Amounted To ',SubTotal:4:2);
            writeln ('You Travel ',PubMiles:4:2,' Miles Weekly On Public Transport');
            writeln ('This Amounted To ',PubTot:4:2);
            writeln ('You Spent ',Hours,' Hours On A Plane Last Year');
            writeln ('This Amounted To ',PlaneTot);
            writeln ('Your Total Annual Transport Score Is ',Total:4:2);
            writeln ('Press Enter To Return To The Menu');
            readln;
            end;
   end;

procedure ExistingUser;
begin
   Login;
   PasswordLog;
   RegDriver;
   Test;
   Pub;
   Flying;
   Calculate;
   Display;
   write (UserFile, User);
end;

procedure EditMiles;
begin
end;


procedure Edit;
   begin
      repeat
         clrscr;
            writeln;
            textbackground (Black);
            textcolor (White);
            writeln ('A: Edit Yearly Mileage');
            textbackground (White);
            textcolor (Black);
            writeln ('B: Edit Car Size');
            textbackground (Black);
            textcolor (White);
            writeln ('C: Edit Public Transport Miles');
            writeln;
            textcolor (Red);
            writeln ('D: Edit Plane Hours');
            writeln;
            textcolor (Yellow);
            writeln ('Enter choice --> ');
            ModChoice := upcase (readkey);
               case ModChoice of
                  'A' : EditMiles;
               else
                  writeln ('Error - only enter A-E. Try again.');
      end;
      until ModChoice = 'F';
     end;



procedure ModMenu;
   begin
      repeat
         clrscr;
         writeln;
         textbackground (Black);
         textcolor (White);
         writeln ('A: Display Current Transport Score And Other Information');
         textbackground (White);
         textcolor (Black);
         writeln ('B: Edit Inputed Data');
         textbackground (Black);
         textcolor (White);
         writeln ('C: Edit Information');
         writeln;
         textcolor (Red);
         writeln ('F: To Return To The Main Menu');
         writeln;
         textcolor (Yellow);
         writeln ('Enter choice --> ');
         MenuChoice := upcase (readkey);
            case MenuChoice of
               'A' : Display;
               'B' : Edit;
            else
               writeln ('Error - only enter A-E. Try again.');
   end;
   until MenuChoice = 'F';
  end;

procedure Modify;
   begin
   Login;
   PasswordLog;
   ModMenu;
   end;



begin {Of Main Program}
   repeat
      clrscr;
      assign (UserFile,'UserInfo.dta');
      textcolor (Green);
      writeln ('-------------------Welcome To Carbon Calculator------------------');
      writeln;
      textcolor (White);
      writeln ('A: New User');
      textbackground (White);
      textcolor (Black);
      writeln ('B: Exisiting User');
      textbackground (Black);
      textcolor (White);
      writeln ('C: Edit Information');
      writeln;
      textcolor (Red);
      writeln ('F: Quit');
      writeln;
      textcolor (Yellow);
      writeln ('Enter choice --> ');
      MenuChoice := upcase (readkey);
      case MenuChoice of
        'A' : CreateUser;
        'B' : ExistingUser;
        'C' : Modify;


      else
         writeln ('Error - only enter A-C. Press Enter To Try again.');
         readln;
      end;
   until MenuChoice = 'F';

   close (UserFile);
end.

Your question is unclear because you have used lots of caps and no punctuation, and barely described the issue.

However..

I believe most of the code you posted is unnecessary, bar the "newuser1" function

But, Im guessing the main part is you need to check your seek worked, and th at you moved to the right point..

noticed an error here...with a quick pass...

if PassCheck <> User.Password then
textbackground (White);
textcolor (Black);
writeln ('The Passwords Did Not Match Please Try Again');
textbackground (Black);

should be

#
if PassCheck <> User.Password then
begin
  textbackground (White);
  textcolor (Black);
  writeln ('The Passwords Did Not Match  Please Try Again');
  textbackground (Black);
end;

I need clarification...

'A' : CreateUser;
'B' : ExistingUser;
'C' : Modify;

On choice "A" should it append the record? If so just move to the end of the file before writing your lines...

He tries to with his

seek(UserFile, filesize (UserFile));

Solved It Thanks For Your Help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.