Reserve block (100? 200?) for custom events.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Reserve block (100? 200?) for custom events.

Post by jassing »

Currently, if I build a project that uses custom events with PostEvent(), I need to enumerate my events:

Code: Select all

Enumerate #PB_Event_FirstCustomValue
...
EndEnumerate
This works fine -- UNTIL (for example) a dll is modified with an updated purebasic version. It then stands the chance of having #PB_Event_FirstCustomValue be a different value; requiring an entire project to be rebuilt.

If there was a reserved block of 100 or 200 or other "Custom Event" #; it would help in the long run.

Perhaps:
#PB_Event_CustomReserve1... #PB_Event_CustomReserve200
and then have #PB_Event_FirstCustomValue remain available for more custom events and to not break current projects that use it.
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: Reserve block (100? 200?) for custom events.

Post by BorisTheOld »

I asked this question when 5.10 was released. Here's Fred's answer.

http://www.purebasic.fr/english/viewtop ... =postevent

It's unlikely that Fred will be changing the base value on a whim. But that said, there's always a risk that any PB feature can change in the future.

If you fret about all the things that might change, then you should quit now and take up a less stressful pastime. :)
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Reserve block (100? 200?) for custom events.

Post by ts-soft »

Named Enumeration should solve this problem:

Code: Select all

Enumeration CustomEvent
  #myfirst = #PB_Event_FirstCustomValue
  #second
  #third
EndEnumeration

;...

Enumeration CustomEvent
  #second_enumeration
EndEnumeration

Debug #third
Debug #second_enumeration
http://www.purebasic.fr/english/viewtop ... 305#p53305
i think this one comes someday :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Reserve block (100? 200?) for custom events.

Post by jassing »

I'm not fretting, it's a wish list forum, no? I simply pointed out how it could be useful.
And no, named enumeration doesn't address the situation.
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: Reserve block (100? 200?) for custom events.

Post by BorisTheOld »

jassing wrote:This works fine -- UNTIL (for example) a dll is modified with an updated purebasic version. It then stands the chance of having #PB_Event_FirstCustomValue be a different value; requiring an entire project to be rebuilt.

If there was a reserved block of 100 or 200 or other "Custom Event" #; it would help in the long run.

Perhaps:
#PB_Event_CustomReserve1... #PB_Event_CustomReserve200
and then have #PB_Event_FirstCustomValue remain available for more custom events and to not break current projects that use it.
Why request, say, 200 reserved events, and that #PB_Event_FirstCustomValue remain immutable?

Fred has already said that event numbers greater than 65536 (#PB_Event_FirstCustomValue) are reserved for custom events. So it seems to me that PB already has what you need.

And as for #PB_Event_FirstCustomValue changing in the future, the same argument could be made for any constant or feature already in PB -- including the fixed range that you request.

As I said, don't fret about it. I suspect that you'll need to recompile your programs because of your own upgrades, long before you need to recompile them because of changes to PB constants.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
Post Reply