943,603 Members | Top Members by Rank

Ad:
Sep 21st, 2009
-1

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

Expand Post »
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, 26 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
turbomen is offline Offline
113 posts
since Feb 2009
Sep 21st, 2009
0

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

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));
Reputation Points: 10
Solved Threads: 4
Newbie Poster
House_of_Dexter is offline Offline
17 posts
since Oct 2008
Sep 21st, 2009
0

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

Hi,

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

Cheers,
Reputation Points: 10
Solved Threads: 0
Junior Poster
turbomen is offline Offline
113 posts
since Feb 2009
Sep 22nd, 2009
1

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

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....
Reputation Points: 132
Solved Threads: 138
Posting Pro
FlamingClaw is offline Offline
559 posts
since Feb 2009
Sep 22nd, 2009
0

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

Dear Sir,

Thank you for your help.

Cheers,
Reputation Points: 10
Solved Threads: 0
Junior Poster
turbomen is offline Offline
113 posts
since Feb 2009
Sep 22nd, 2009
0

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

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;
Reputation Points: 10
Solved Threads: 4
Newbie Poster
House_of_Dexter is offline Offline
17 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: C/C++ to Delphi
Next Thread in Pascal and Delphi Forum Timeline: How to spead a loop?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC