GETFILESIZE

Previous topic - Next topic

Hemlos

GETFILESIZE doesnt work when it is called after a file has been opened for reading.

Quote from: MrTAToad on 2012-Dec-10
It should be noted that DEBUG wont display a value properly
Bing ChatGpt is pretty smart :O

erico

I keep telling people we are so pro at GLB boards that some questions or bug reports get solved in less than 2 posts! :D ;)

kanonet

Haha. :nana:

Just for clarification, REVINSTR, did not have an error, but GETFILESIZE has?
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Hemlos

Correct kanonet
Getfilesize seems odd bug, I can't seem to get my file object module to get its own size from within the type. But it does work when called from outside the module.

I always get 0 size if I try self._Get_file_KB()   But from outside this works fine where: fileObj._get_file_KB()  this works fine . The file name I use is a defined type value ie self.Name$
Bing ChatGpt is pretty smart :O

kanonet

Just did a test on my own and GETFILESIZE works inside a type for me (on V11).
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

MrTAToad

Hemlos - do you have some example code ?

Hemlos

Yes

here is a working sample showing it working in and out of the type.

the first call is from the method  _File_Into_List()

the second call is at the bottom of the main program source, this one works fine.

[attachment deleted by admin]
Bing ChatGpt is pretty smart :O

MrTAToad

The main cause is that GETFILESIZE is an int64, and it appears that the return value is either corrupt in a TYPE or most commands aren't able to deal with it properly...

kanonet

I found it, its no bug:
You can not use GETFILESIZE when that file is currently open! Move your call to self._get_kb() inside _File_into_list behind the CLOSEFILE and everything will work fine.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Hemlos

thanks guys
Bing ChatGpt is pretty smart :O

MrTAToad

It should be noted that DEBUG wont display a value properly

Wampus

#11
Actually I can't get GETFILESIZE() to return the file size in IDE 11.171 regardless of a file being open or closed. Tested on Windows 7 and XP using this proggy: http://www.glbasic.com/forum/index.php?topic=7639.0

Works fine in IDE 10.283 on Windows 8.

[Edit: Also not returning file size compiled to Android with IDE 11.171. Tested on Nexus 7]

kanonet

#12
GETFILESIZE works in V11. But in V11 it returnes an int64 not an integer like before. And it looks like Gernot forgot to include an easy automatic int64 to string conversation like we have it for normal integers.
So PRINT GETFILESIZE() does not work but a%=GETFILESIZE; PRINT a% works. Of cause you may get wrong results for big files (but you have same problem in V10).
Better use PRINT FORMAT$(0,0,GETFILESIZE()) this should work without loosing informations.
EDIT: i think i was wrong with FORMAT$(), i think it converts int64 to integer when you call it and then converts the integer to string - which would mean you get the same problem with big files like in V10, but at least it works for small files.

My two suggestions for Gernot would be:
-add automatic type conversation int64 to string
-accepting int64 input into FORMAT$(), if its not the case yet (maybe other functions need this too? And what is with math, can we calculate with int64 [+other data types] outside of integer range?)
-add informations int64 to helpfile, in section data types and for GETFILESIZE
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Kitty Hello

oops. thanks for mentioning.