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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

D3 to D7 string save difference?

Status
Not open for further replies.

sggaunt

Programmer
Jul 4, 2001
8,620
GB
I am upgradeing an application written in D3 to D7, the code is the same.
But I am getting an odd effect.
The original program saved data files with the stringlist savetofile method. Lines of text have been added to the string list with add(string); This should terminate each line with a CR ??

The lines are read back in (in blocks of 15) using this code
Code:
      begin
         for c := 0 to 15 do
           begin
              Readln(F, S);
          //etc

This worked as expected originaly.
But the D7 version dosnt seem to see the ends of the lines and reads the files as one long string.

If I view the files in notepad it is also displayed as one string with a small rectange where the CR should be.
If I edit this and put in a return then the D7 program reads it correctly.
The D3 executable can read the files in either format.
Does anyone know why this is happening.


[red]GNBM 4th Feb[/red] More on and other neat UK stuff at forum1091
Steve: Delphi a feersum engin indeed.
 

To see what is really happening, look at the data with a hex editor. It sounds like D3 is not inserting the customary CRLF sequence (#13#10) but is only inserting one or the other.

What I don't understand is: If you are using SaveToFile, why are you not being consistent and using LoadFromFile to go "the other way"?

 
As I recall reading, the default length variable for "string" changed from one byte to two bytes. You might check if this is a difference between D3 and D7.

Usually for "string", Delphi operates off that length value to determine how much to show.
 
Cheers for that Glenn
Zathras: You are correct, I wrote this some time ago and it dosnt use savetofile as I thought it saves with writeln!
But I think with this update I may change this to use stringlist.savetofile & loadfromfile.



[red]GNBM 4th Feb[/red] More on and other neat UK stuff at forum1091
Steve: Delphi a feersum engin indeed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top