- #PB_Event_FirstCustomValue
- #PB_EventType_FirstCustomValue
- GetFreeEventNumber
- GetFreeEventTypeNumber
Code: Select all
;-TOP
Macro MyEvent_NextCustomValue
($7FFFFFFF - MacroExpandedCount)
EndMacro
Macro MyEventType_NextCustomValue
($7FFFFFFF - MacroExpandedCount)
EndMacro
Debug MyEvent_NextCustomValue
Debug MyEvent_NextCustomValue
Debug MyEvent_NextCustomValue
Debug MyEventType_NextCustomValue
Debug MyEventType_NextCustomValue
Debug MYEventType_NextCustomValue
Code: Select all
Macro PB_Event_NextCustomValue
($FFFF + MacroExpandedCount)
EndMacro
Macro PB_EventType_NextCustomValue
($3FFFF + MacroExpandedCount)
EndMacro
If you don't use third-party include codes, this is how you can solve the problem:Little John wrote:Sorry, I don't understand the reason for this feature request.
Can you please explain it?
Code: Select all
; Content of include file "whatever1.pbi":
Enumeration CustomEvents #PB_Event_FirstCustomValue
#myCustomEvent1
#myCustomEvent2
#myCustomEvent3
#myCustomEvent4
EndEnumeration
; End of include file "whatever1.pbi"
; Content of include file "whatever2.pbi":
Enumeration CustomEvents
#myCustomEvent5
#myCustomEvent6
EndEnumeration
; End of include file "whatever2.pbi"
; Main code
Debug #myCustomEvent1 ; = #PB_Event_FirstCustomValue
Debug #myCustomEvent2 ; = #PB_Event_FirstCustomValue + 1
Debug #myCustomEvent3 ; = #PB_Event_FirstCustomValue + 2
Debug #myCustomEvent4 ; = #PB_Event_FirstCustomValue + 3
Debug #myCustomEvent5 ; = #PB_Event_FirstCustomValue + 4
Debug #myCustomEvent6 ; = #PB_Event_FirstCustomValue + 5
Code: Select all
; Content of include file "whatever1.pbi":
Enumeration #PB_Event_FirstCustomValue
#myCustomEvent1
#myCustomEvent2
#myCustomEvent3
#myCustomEvent4
EndEnumeration
; Followed by more code
; End of include file "whatever1.pbi"
; Content of include file "whatever2.pbi":
#Event_whatever = #PB_Event_FirstCustomValue
; Followed by more code
; End of include file "whatever2.pbi"
; Main code
Debug #myCustomEvent1 ; = #PB_Event_FirstCustomValue
Debug #myCustomEvent2 ; = #PB_Event_FirstCustomValue + 1
Debug #myCustomEvent3 ; = #PB_Event_FirstCustomValue + 2
Debug #myCustomEvent4 ; = #PB_Event_FirstCustomValue + 3
Debug #Event_whatever ; = #PB_Event_FirstCustomValue
Code: Select all
; Content of include file "whatever1.pbi":
#myCustomEvent1 = GetFreeEventNumber
#myCustomEvent2 = GetFreeEventNumber
#myCustomEvent3 = GetFreeEventNumber
#myCustomEvent4 = GetFreeEventNumber
; Followed by more code
; End of include file "whatever1.pbi"
; Content of include file "whatever2.pbi":
#Event_whatever = GetFreeEventNumber
; Followed by more code
; End of include file "whatever2.pbi"
; Main code
Debug #myCustomEvent1 ; = #PB_Event_FirstCustomValue
Debug #myCustomEvent2 ; = #PB_Event_FirstCustomValue + 1
Debug #myCustomEvent3 ; = #PB_Event_FirstCustomValue + 2
Debug #myCustomEvent4 ; = #PB_Event_FirstCustomValue + 3
Debug #Event_whatever ; = #PB_Event_FirstCustomValue + 4
Code: Select all
Enumeration GetFreeEventNumber
#myCustomEvent1 ; = #PB_Event_FirstCustomValue
#myCustomEvent2 ; = #PB_Event_FirstCustomValue + 1
#myCustomEvent3 ; = #PB_Event_FirstCustomValue + 2
#myCustomEvent4 ; = #PB_Event_FirstCustomValue + 3
EndEnumeration
Enumeration GetFreeEventNumber
#myCustomEvent5 ; = #PB_Event_FirstCustomValue + 1
#myCustomEvent6 ; = #PB_Event_FirstCustomValue + 2
#myCustomEvent7 ; = #PB_Event_FirstCustomValue + 3
#myCustomEvent8 ; = #PB_Event_FirstCustomValue + 4
EndEnumeration
I see now. Thanks for your detailed explanation. I didn't think of third-party include codes.Sicro wrote:But if you use third-party include codes, it could look like this:
I think with a new function such as GetFreeEventNumber(), things will work reliably only if this function and nothing else will be used for generating event numbers. Enumerations shouldn't be used at all in this context:Sicro wrote:But I see now that we have a new problem:
Code: Select all
; WRONG:
Enumeration GetFreeEventNumber()
#MyEvent1
#MyEvent2
#MyEvent3
EndEnumeration
; CORRECT:
#MyEvent1 = GetFreeEventNumber()
#MyEvent2 = GetFreeEventNumber()
#MyEvent3 = GetFreeEventNumber()
Code: Select all
CompilerIf Defined(CommonConstants, #PB_Module) = 0
DeclareModule CommonConstants
; Form
Enumeration FormWindow
EndEnumeration
Enumeration FormGadget
EndEnumeration
Enumeration FormMenu
EndEnumeration
Enumeration FormImage
EndEnumeration
Enumeration FormFont
EndEnumeration
; Event
Enumeration EventCustom #PB_Event_FirstCustomValue
EndEnumeration
Enumeration EventTypeCustom #PB_EventType_FirstCustomValue
EndEnumeration
EndDeclareModule
Module CommonConstants
EndModule
CompilerEndIf
UseModule CommonConstants
Code: Select all
Macro GetFreeEventNumber
; MacroExpandedCount is used to reduce the unused value range
(#PB_Event_FirstCustomValue + #PB_Compiler_Line - MacroExpandedCount)
EndMacro
Enumeration GetFreeEventNumber
#CustomEvent1
#CustomEvent2
#CustomEvent3
EndEnumeration
Enumeration GetFreeEventNumber
#CustomEvent4
#CustomEvent5
#CustomEvent6
EndEnumeration
Debug #CustomEvent1
Debug #CustomEvent2
Debug #CustomEvent3
Debug #CustomEvent4
Debug #CustomEvent5
Debug #CustomEvent6
Debug GetFreeEventNumber