Start New Discussion within our Software Development Community

I want to show a simple example about writing record to a file,and for checking,read back from that file.
Created By FlamingClaw

Program Solution01;

Uses
     Crt;

Type
     Str30=String[30];
     Rdata=Record
              FirstName:Str30;
              LastName:Str30;
              Phone:LongInt;
              Year:Integer;
              Month:1..12;
              Day:1..31;
              Notes:Str30;
           End;

Var Member:Rdata;
    F:File Of Rdata;

Begin
  ClrScr;
  With Member Do Begin
     FirstName:='Flaming';
     LastName:='Claw';
     Phone:=123456;
     Year:=1978;
     Month:=11;
     Day:=16;
     Notes:='Member of the FireStormTeam';
  End;

  Assign(F,'C:\Records.dat');
  Rewrite(F);
  //we'll write the above record to Records.dat file
  Write(F,Member);

  WriteLn;
  WriteLn('Record writing is done.Press Enter to continue...');
  ReadLn;

  While (EoF(F)=False) Do Begin
     Read(F,Member);
  End;

  WriteLn;
  Write('Press enter to see the readed results:');
  ReadLn;
  WriteLn;
  WriteLn('This is one record''s contents: ');
  WriteLn;
  WriteLn('Name: ',Member.FirstName,' ',Member.LastName);
  WriteLn('Phone Number: ',Member.Phone);
  WriteLn('Birth''s Year: ',Member.Year);
  WriteLn('Birth''s Month: ',Member.Month);
  WriteLn('Birth''s Day: ',Member.Day);
  WriteLn('Notes about ',Member.FirstName,' ',Member.LastName,': ',Member.Notes);
  WriteLn;
  Write('Press enter to close the file');
  ReadLn;
  Close(F);
  Write('Press enter to quit...');
  ReadLn;
End.

(*

-=Created by FlamingClaw 2009.04.20=-
-=Created and Tested in Turbo Pascal 7.0.=-

*)
The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.