Page 2 of 2

Posted: Thu May 22, 2008 1:11 pm
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.

Posted: Thu May 22, 2008 1:13 pm
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

Posted: Thu May 22, 2008 9:09 pm
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.