Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New Line in FileStream

Status
Not open for further replies.

Tilen

Programmer
Apr 2, 2005
75
SI
Hi

please help me with this one.

I have a 2 dimensional array I would like to store into filestream.

TRec = record
Id:integer;
Name:string;
Prop_id:integer;
end;

As I tried I could only save records into filestream as one by one in one go. So everything is in one line.
The problem is to reverse the process, to load records back into array. So I put 'delimiter' between data, like '&&&&&'.
So line wold be:

1&&&&&ABC&&&&&0&&&&&2&&&&&DEF&&&&&0&&&&&3&&&&&GHI&&&&&1

this line shows 3 records. And I would load data into TList and extract each data into one line, so I would have :

List[0]=1
List[1]=ABC
List[2]=0
List[3]=2
List[4]=DEF
List[5]=0
List[6]=3
List[7]=GHI
List[8]=1

then I would go and process each three lines into one array record.

this works.

But I would like to make it more 'clean'.

How would I put a 'new line'/'line feed' at the en of each record, so I would have each record in it's own line in filestream?

Then this would be much easier to do, store and to load back in.


If anybody has any suggestions how to do this differently, please let me know.

Thanx a lot
Tilen
 
As I can remember newline was with character #13 or #10. Don't have a Delphi now and Can't tell you exactly which one is. Try both of them.

Spent
 
New line #10
Line feed #13

Steve: Delphi a feersum engin indeed.
 
In other words, you need to use both:

'line 1'#10#13'line 2'

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
Great Delphi Websites faq102-5352
 
Sorry, forgot to add that #10 alone works unix/linux systems.

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
Great Delphi Websites faq102-5352
 
BobbaFet in DOS/Windows the sequence is CrLf ie #13#10, I don't know whether #10#13 would make a difference or not, but I think some programs would not recognise it.


Hope this helps.
 
Yes, you are right, that is my mistake... need more coffee...

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
Great Delphi Websites faq102-5352
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top