[Gambas-user] problem with the File class

Jean-Francois Perreault cmcpero at ...142...
Thu Mar 3 19:23:50 CET 2005


Hi,

I'm trying to read files into strings but I have a problem getting the 
size of the opened file

here's the relevant bits

DIM nesdb as File
OPEN "/home/shodan/nes.txt" FOR READ AS #nesdb
PRINT nesdb.size
CLOSE #nesdb

and in the console I get 0

but if I add
READ #nesdb, sRead , 38238
TextArea1.Text = sRead
label1.text = len(sRead)

I get the entire file printed out in textarea1 and 38238 in label1
I tried setting the third parameter of READ to -1 , the doc says it 
should read until the end of the stream (to the end of file in case of a 
file ?)

but -1 only reads on character , and 0 or unset only read character 2 to 
40 (probably data-dependant , the doc says the file must have been 
written to with WRITE in this case)
if I print Stat("/home/shodan/nes.txt").Size
I get 38238 on the console so I can use that , but I was just wondering 
why the File.Size property wasn't working




More information about the User mailing list