Is there a way to increase the 10,000 gadget limit?

Just starting out? Need help? Post your questions and find answers here.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Seldon wrote:
freak wrote:The IDs are allocated in an array, so using them sparsely is a waste of memory.
What do you mean exactly ?? If I do something like this:

Code: Select all

#ID_GADGET=2000
ButtonGadget(#ID_GADGET,9,9,33,33,"Button",#PB_Button_Toggle)
Does PB create an arrary of 2000 elements although I only use one gadget ? :shock:
Exactly. Read the part that Trond quoted from the manual.
Thats why there is a debugger check in place to warn about very high object numbers.

> so it's recommend to use Enumeration /EndEnumeration or PB_Any i mean ?

If you know how many gadgets you create (like for the usual gui), i recommend
the Enumeration, as you do not have to keep track of the generated IDs yourself.
If you have a variable number of objects to create (for example if there can be a
variable number of withdows with the same gui), then #PB_Any is the way to go.
Using fixed numbers and using them sparsely to allow for the dynamic number is not
the best solution as noted above.

Some people also use #PB_Any exclusively simply because they find it more intuitive.
Its a matter of preference really.
quidquid Latine dictum sit altum videtur
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post by Thalius »

Seldon wrote:
freak wrote:The IDs are allocated in an array, so using them sparsely is a waste of memory.
What do you mean exactly ?? If I do something like this:

Code: Select all

#ID_GADGET=2000
ButtonGadget(#ID_GADGET,9,9,33,33,"Button",#PB_Button_Toggle)
Does PB create an arrary of 2000 elements although I only use one gadget ? :shock:
Yes - this allows also somewhat static Gadget Management. But if you start with a ID like that then yes - waste of Memory - i recommend using #PB_Any for any bigger amount of gadgets anyway.

EDIT: Arr! fr34k beat me - heh ;)

Thalius
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone! ;)"
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

Post by Seldon »

OK, thanks. Actually I use #Enumaration for all my programs, but I have a project where I defined the GUI constants statically. I did something like this:

Code: Select all

#Window_1=1
#Window_1_Button_1=11
#Window_1_Button_2=12
#...
#Windows_Button_23=123
;
#Window_2=2
#Window_2_Button_1=21
#Window_2_Button_2=22
#...
#Windows_2_Button_15=215
I don't remember why I did this way, maybe for some kind of optimations, though (now I know) I wasted some memory.
Post Reply