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; 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.=- *)
About the Author
Just living in hungary.Teaching myself in pascal.
I have time to programming when I'm going to home,cause my job is not a good place for that.
Don't forget that if you ask something on the forum and you got the right answer then
[b] mark as solved !![/b]