gadget ID ++

Just starting out? Need help? Post your questions and find answers here.
stan
User
User
Posts: 29
Joined: Tue Jun 10, 2003 2:46 pm

gadget ID ++

Post by stan »

Hi,

Do gadget (or other items) number have to be constants ? From the limired tests I have conducted it seems that the answer is no, that is :

for a = 1 to 10
String Gadget( a, ...
next a

seems to work and I can use the created gadget, but I wonder if nothing bad is lurking around ...

Is there a limit on the number of gadgets, menus, menus items, list items ?

TIA.

Bests.

Stan.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Stan,

A Constant is just a placeholder for a number. There is no difference to the computer between using a number or a constant.

The real difference is to you the programmer. Using numbers instead of constants makes you code look like this:

Code: Select all

  SetGadgetText(12) = "Purebasic"
rather than:

Code: Select all

  SetGadgetText(#LanguageUsed) = "Purebasic"
So there is no problem using numbers instead of constants, especially if your dynamically generating controls at runtime. Just keep in mind the readability and maintainability of your code.

If you are generating gadgets on the fly, you might want to consider using arrays and structures to keep track of them.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Also keep in mind that every gadget needs a unique ID!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
stan
User
User
Posts: 29
Joined: Tue Jun 10, 2003 2:46 pm

Post by stan »

Ok, thanks ...

Stan.
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

Karbon wrote:Also keep in mind that every gadget needs a unique ID!
Only every gadget you want to process or change in the app during runtime needs an unique ID.
There is no problem when using 1000 times the same ID for static Textgadget fo example.
Every gadget you draw in the PureBasic Visual Designer got the same ID internaly. Not in generated source of course.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Good point, Berikco!

I sit corrected :-)
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
aszid
Enthusiast
Enthusiast
Posts: 162
Joined: Thu May 01, 2003 8:38 pm
Location: California, USA
Contact:

Post by aszid »

another valid point would be that if you use arrays or such to create multiple copies of the same window, then you don't necarrarily need to use unique gadget id's for each window, as long as you check the windowid when an event happens.

i'm currently working on a project with dynamically generated windows, that i could open (in theory) an infinate amount of.
--Aszid--

Making crazy people sane, starting tomorrow.
Post Reply