problem to read file

kalarius

Active Member
Licensed User
Longtime User
on my program I have write
at global
dim Tr as Textreader
dim List1 as LIST
dim Fposition as string , Fsign as string

at activity

list1.initialize("List1")

TR.Initialize2(File.OpenInput("\mnt\sdcard","smsposition.txt", "windows-1253")
list1=tr.readlist
the file have only 2 lines
Fposition=list1.get(0)
Fsign=list1.get(1)

util now alll are very good
now I have an other file the sms.txt This file have 8 lines
I transfer the sms.txt file to the card useing the SMB libary.

now I use the command
TR.Initialize2(File.OpenInput("\mnt\sdcard","sms.txt", "windows-1253")
list1=tr.readlist

and here is the problem the list1.size-1=-1 (it does not read the file)

I have eject the card to my pc and I read the card and there ie the file and inside are 8 lines of data

something is going wrong with the second initialize but I do not know what

Kalarakis Mixalis
Greece
 

mc73

Well-Known Member
Licensed User
Longtime User
Κάνεις initialize την list1 για δεύτερη φορά; Πού κλείνεις την TR; Αν θέλεις, κάνε αντιγραφή-επικόλληση την περιοχή ανάγνωσης εδώ, και καλά είναι να χρησιμοποιείς τα code και /code εντός αγκυλών, στην αρχή και το τέλος του κώδικα, ώστε να είναι πιο ευανάγνωστος.
 
Upvote 0

kalarius

Active Member
Licensed User
Longtime User
I do not close the TR. because the manual refers that it open the stream, read the files content and close it. I will use the tr.close it is possible a mistake of the manual or a bug into the libray.
Also at the textwiter at the initialize refer that it get only one parameter and at the write example it initialize it with second parameter, False


το Τr Δεν το κλείνω γιατί το εγχειρίδιο λέει ότι ανοίγει το stream διαβάζει και το κλείνει μόνο του. Αλλά μέλλον δεν είναι σίγουρο. Είδα επιπλέον στο initialize ότι έχει και ένα false ΑΛΛΑ στο εγχειρίδιο δεν αναφέρει δεύτερη παράμετρο. Στο παράδειγμα όμως έχει σαν δεύτερη παράμετρο το false. Είναι στο παράδειγμα του textwriter>> write
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Which manual says that the stream is closed automatically with TextReader? And where is the wrong write example?

Probably he is referring to page 215 of the beginner's guide v1.6, at the bottom.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Also at the textwiter at the initialize refer that it get only one parameter and at the write example it initialize it with second parameter, False

Nope. The 'false' parameter is for the file.OpenOutput statement. At the end of the line in the example, you can see 2 parentheses. The first is for the file.openOutput, the second is for the writer.Initialize.

Working a lot with streams, I can assure you that I found nothing buggy so far.
 
Last edited:
Upvote 0
Top