Android Question [SOLVED] File.readlist, first item is empty

alwaysbusy

Expert
Licensed User
Longtime User
Hi,

I'm trying to read a file using the file.readlist() method. For some reason the first item in the list is empty, although there is no CR of LF at the beginning.

Attached is the file in question, and here is the hex view of the first bytes:

HexDump.png


Any ideas why?
 

Attachments

  • FYTO_Alain_STRUCTURE.zip
    710 bytes · Views: 151

alwaysbusy

Expert
Licensed User
Longtime User
The files are created in another language (Xojo on PC). They contain the description of a SQLite database that B4A reads and then uses to create the db.

Only three lines in it:

First line:
<Database>FYTO_Alain.sq3</Database> <-CR

second line:
<Table>FYTO_REGISTRATIE;4,FYTO_REGISTRATIE_SYSID,FYTO_REGISTRATIE_SYSID,0;4, .......</Table> <-CR

Third line:
<Screens>4:27;5:12;6:5;7:26;8:5;9:5;10:11;11:11;16:6;17:6;13:25;12:25;19:19;18:25</Screens> <-CRLF

Code:

Dim txtIN As List
txtIN.Initialize
txtIN = File.ReadList(mGlobal.BuildPath, "CurrentDB.Schema")

Result in txtIN after this code:

txtIN.Get(0)<- the weird empty string
txtIN.Get(1) <Database>FYTO_Alain.sq3</Database>
txtIN.Get(2) <Table>FYTO_REGISTRATIE;4,FYTO_REGISTRATIE_SYSID,FYTO_REGISTRATIE_SYSID,0;4, .......</Table>
txtIN.Get(3) <Screens>4:27;5:12;6:5;7:26;8:5;9:5;10:11;11:11;16:6;17:6;13:25;12:25;19:19;18:25</Screens>
txtIN.Get(4)<- an ampty string, but this one makes sence as there is an CRLF at the end, ergo ReadList makes two lines
 
Upvote 0

Troberg

Well-Known Member
Licensed User
Longtime User
My first instinct in cases like these is to check character encoding. Is it one encoding and ReadList expects another?

Otherwise, simplify. Make a simple file (in a texteditor) with, say, A, B, C and D in it, just to make sure there isn't anything you don't see in the data. If this doesn't work, it's probably Erel's problem, if it works, well, then you can gradually do more complex test cases until you find the problem.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Ok , found it. Just for further reference if someone else encouters this.

The problem is the mix of the two type of EOLs I used. If I use all CR chars OR all CRLFs, readlist works as expected.

But because in my case I used CR for every line, and CRLF at the end, ReadList() somehow got confused.
 
Upvote 0
Top