Problem with WriteList and ReadList

klaus

Expert
Licensed User
Longtime User
Hi Erel,

In the attached test ptogram I save a List of typed variable data with WriteList and read it back with ReadList.
The returned List size is 4 times the original size.
There are extra commas in the list read back, why?
Best regards.
 

Attachments

  • SaveListType.zip
    5.7 KB · Views: 308

vb1992

Well-Known Member
Licensed User
Longtime User
Looks like there is a few LINE FEEDS popping up
Asc(10)

See Log Window
 

Attachments

  • line-feeds.zip
    6 KB · Views: 274
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
File.WriteList writes a line for each item, as vb1992 wrote, some of the items span over more than a single line. When you use File.ReadList it takes each line and treats it as a string item.

These methods should not be used with custom types. You should instead use RandomAccessFile.WriteObject / ReadObject. These methods create a binary file that keeps the original structure.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Or replace the line delimiter character with something like %n%, something that doesnt occur in your regular data
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…