How can I write a program that writes to a text file?

Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Feb 2009
Posts: 93
Reputation: turbomen is an unknown quantity at this point 
Solved Threads: 0
turbomen turbomen is offline Offline
Junior Poster in Training

How can I write a program that writes to a text file?

 
-1
  #1
Sep 21st, 2009
Dear ALL,

Could you tell me how can I write a program that writes to a text file, the 32 people that are in our hotSeat.txt file.

Cheers,

turbomen

(p.s.: 'the question orginally ask me to write a program that writes to a text file, the 32 people that are in our hotSeat.dat file' but it is not possible for me to upload the *.dat file to here. So, I have make changes of the *.dat file to *.txt file before upload it.)
Attached Files
File Type: txt hotSeat.txt (1.6 KB, 4 views)
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 16
Reputation: House_of_Dexter is an unknown quantity at this point 
Solved Threads: 3
House_of_Dexter House_of_Dexter is offline Offline
Newbie Poster

Re: How can I write a program that writes to a text file?

 
0
  #2
Sep 21st, 2009
What are you using Turbo Pascal or Delphi? If Turbo Pascal...look at AssignFile/Append/CloseFile

if Delphi...use TFileStream

something like
aStream.Write(Pointer(aStringToWrite)^, length(aStringToWrite));
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 93
Reputation: turbomen is an unknown quantity at this point 
Solved Threads: 0
turbomen turbomen is offline Offline
Junior Poster in Training

Re: How can I write a program that writes to a text file?

 
0
  #3
Sep 21st, 2009
Hi,

Thank you for your kind reply. I am using Borland Delphi but what is TFileStream?

Cheers,
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 447
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 106
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

Re: How can I write a program that writes to a text file?

 
1
  #4
Sep 22nd, 2009
first you have to know the record's field,if you know then you can use a for loop to write the guy to the file....
By the way,when we want to write records into a file then we do it with typed file,same typed as the record....
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 93
Reputation: turbomen is an unknown quantity at this point 
Solved Threads: 0
turbomen turbomen is offline Offline
Junior Poster in Training

Re: How can I write a program that writes to a text file?

 
0
  #5
Sep 22nd, 2009
Dear Sir,

Thank you for your help.

Cheers,
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 16
Reputation: House_of_Dexter is an unknown quantity at this point 
Solved Threads: 3
House_of_Dexter House_of_Dexter is offline Offline
Newbie Poster

Re: How can I write a program that writes to a text file?

 
0
  #6
Sep 22nd, 2009
Simple example...

Pascal and Delphi Syntax (Toggle Plain Text)
  1. a_FileStream := TFileStream.Create(FFileName, fmCreate);
  2. try
  3. for a_Index := Low(a_RecordArray) to High(a_RecordArray)
  4. begin
  5. aStream.Write(Pointer(a_RecordArray[a_Index].LastName)^, length(a_RecordArray[a_Index].LastName));
  6. end;
  7. finally
  8. a_FileStream.Free;
  9. end;
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC