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.)

Recommended Answers

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));

Jump to Post

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....

Jump to Post

All 5 Replies

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));

Hi,

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

Cheers,

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....

Dear Sir,

Thank you for your help.

Cheers,

Simple example...

a_FileStream := TFileStream.Create(FFileName, fmCreate);
  try
    for a_Index := Low(a_RecordArray) to High(a_RecordArray)
    begin
       aStream.Write(Pointer(a_RecordArray[a_Index].LastName)^, length(a_RecordArray[a_Index].LastName)); 
    end;
  finally
    a_FileStream.Free;
  end;
Be a part of the DaniWeb community

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