Page 1 of 1
#File object number very high (over 1000), You sure of that?
Posted: Thu Mar 15, 2012 9:40 pm
by treebolt
Using PureBasic 4.1
I get this error when I try to run my code and I use a number larger than 1000 for my #File parameter in OpenFile, etc.
If I make an EXE it will run fine
Why is this dangerous?
Re: #File object number very high (over 1000), You sure of t
Posted: Thu Mar 15, 2012 9:47 pm
by ts-soft
If you use a number of 1000, PB allocates 1001 Objectstructures for the Fileobjects
It is only a compilerwarning, you can ignore this, but it is better to use a small number
with Enumeration:
Code: Select all
Enumeration ;files
#file1
#file2
EndEnumeration
or use #PB_any.
Re: #File object number very high (over 1000), You sure of t
Posted: Thu Mar 15, 2012 10:06 pm
by treebolt
Thanks for the info
my program will sometimes open / lock more than 1000 files at a time. Is there any danger in doing this ?
Re: #File object number very high (over 1000), You sure of t
Posted: Thu Mar 15, 2012 10:17 pm
by STARGĂ…TE
you open / lock 1000 file in one time ?
if you lock it step by step you can use the same number for all, but close files befor open the next!!
or you #PB_Any to open many files
Re: #File object number very high (over 1000), You sure of t
Posted: Fri Mar 16, 2012 5:59 pm
by treebolt
I want to keep the files locked so that they cannot be overwritten while the program is running. Even when I use #PB_Any when opening files it will sometimes reach a value greater than 1000 and the program will crash when trying to run it from PureBasic. It's getting annoying to have to create an EXE every time I want to test my program.
EDIT: Scratch it, I modified my program to use #PB_Any everywhere it tries to open / create a file and it's fine. I'm still curious as to why it's dangerous to use a number greater than 1000 or have more than 1000 files locked / open at a time. Seems like a crazy thing to cause a program to crash through the debugger.
Re: #File object number very high (over 1000), You sure of t
Posted: Fri Mar 16, 2012 6:06 pm
by Shield
Code: Select all
DisableDebugger
OpenFile(2000, "file.txt")
EnableDebugger
Edit:
treebolt wrote:I'm still curious as to why it's dangerous to use a number greater than 1000 or have more than 1000 files locked / open at a time.
As ts-soft said it's unnecessary memory consumption.
Also, as far as I know, the maximum number of handles for files, windows etc. are limited by the OS.
Re: #File object number very high (over 1000), You sure of t
Posted: Fri Mar 16, 2012 6:07 pm
by treebolt
Shield wrote:
Code: Select all
DisableDebugger
OpenFile(2000, "file.txt")
EnableDebugger
Ahh, had no idea it was possible to disable the debugger through code. Pretty nifty.
Still, anyone know why it's 'dangerous' ? There has to be a reason this limitation exsists
Re: #File object number very high (over 1000), You sure of t
Posted: Fri Mar 16, 2012 6:09 pm
by Shield
See my edit...we should stop editing posts and just make double posts.
