#PB_ANY for MenuItem

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

However, enumerations are worthless for what you previously mentioned. You still have to hard code the constants to be enumerated. Which effectively limits your "visual designer" software to a hard coded number, which is... useless :)

The reason for #PB_ANY for menuitem is for people like us creating visual designers and the like (as well as skin makers). The user can create how ever many number of menu items w/o having to worry about clashes and errors.

My visual designer creates dynamic code, as it assumes people wants to be able to easily extend the code w/o being statically limited by enumerations, and the like.

Every time I end up creating a forum or any kind of project with PV, I end up spending another 30mins to 1 hour fixing up the generated code to be dynamic.

I guess it could be considered a matter of taste. But for most of the projects I work on, requires to be easily extensable after a certain amount of time, so why not have that support in from th beginning?
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Every time I end up creating a forum or any kind of project with PV, I end up spending another 30mins to 1 hour fixing up the generated code to be dynamic.
Hmm, we have written quite a number of professional commercial applications using PV and PB and have never been limited by the code produced. In fact it has allowed us more flexability than anything, not to mention the huge speed increase in the design process!

I guess difference here is the coding skills and knowledge :wink:
Image Image
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

exactly ;)
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

i'm totally in the enumeration camp... shanarra, could you give an example? (or did i overlook it?)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Ok, an exerpt from a visual designer (the same situation applies to all scripting applications).. (Please note, this is for all use of #PB_ANY and not just menu items, even though it certainly applies here!)

With enumerations, I would need to set aside so many place holders and hope that this will not over flow or be under used (impossible). So I set asside 100 enumerations just for "dynamic" controls needed for designing.

Code: Select all

  Enumeration
    #MaybeUse0 ; Will be 0
    #MaybeUse1 ; Will be 1
    #MaybeUse2   ; Will be 2
    .....
    #MaybeUse100
  EndEnumeration
Now with any wide spread, professional commercial application, 100 gadgets will not be enough (luckily, we have a partial implimentation of #PB_ANY available to fix this problem). Now with the problem above, we must first type out each and every single constant to use. For dynamic reasons, enumerations are worthless, as you must GUESS how many # of enumerations the user (or scripter, or designer, etc) will use, effectively either creating a hard cap on how many they can use, OR wasting memory & hard drive space (application bloat).

The dynamic use of #PB_ANY actually prevents bloat :) Back to the issue. Not only do you have to create tons of enumerations, you must also reference these constants individually through out the code. It can be a painfull experience to say the least.

With the use of #PB_ANY... you can use the following

Code: Select all

Structure strDynGadget
DynGadget.l
EndStructure

Newlist DynGadget.strDynGadget()

AddElement(DynGadget())
DynGadget()\DynGadget = ButtonGadget(#PB_ANY, 10, 10, 200, 20, "Standard Button") 

Want to look it up? Grab it from the link list. This is 100% dynamic. No bloat, no wasted hard drive space, nor ram. This is all a consideration when creating commercial software. If there was two programs, one coded the old way (enumerations), and one coded the #PB_ANY way, and they both do the same thing, except the old way inheritally uses way more resources. Which one would you choose? Commercially? Regular users usually dont care about these things, but companies do.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

well, i'm not so sure more resources are actually used, to be honest :-) constants are only inserted when used

the current solution indeed has the problem that external (include) files may use the same numbers for gadgets as your main code

on the other hand, how difficult is it to write a 'unique id' procedure that returns unique / free numbers?

so codewise it could be easily circumvented, perhaps slightly less comfortable, but still...

or am i suffering from a lack of sleep and too much farscape? :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

LOL @ Shanarra !!!

After seeing your logic and how you assume things must work, I can better understand why you have such a hard time coding.

Enjoy :)
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

Heh, well, at first I thought you accidently mispelled my name, but seeing how you have done it twice now... insulting me on purpose? :P

As for assuming how things work... what are you talking about? I know its not in the commercial aspect, been there done that. As for the coding part.. I use the PB manual...if that is wrong.. how about you enlighten us concerning your assumption of me assuming...
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Post by Seymour Clufley »

I know this is an old thread but I really want #PB_Any for the MenuItem command, so just adding my voice. :
Post Reply