Enumeration #PB_Event_FirstCustomValue

Just starting out? Need help? Post your questions and find answers here.
Wolfram
Enthusiast
Enthusiast
Posts: 604
Joined: Thu May 30, 2013 4:39 pm

Enumeration #PB_Event_FirstCustomValue

Post by Wolfram »

I use Enumeration #PB_Event_FirstCustomValue in different files which I include in one main file.
Is it normal that they have the same value?
I would expect it starts with the next higher value.

FileA.pb

Code: Select all

Enumeration #PB_Event_FirstCustomValue
  #A
  #B
EndEnumeration
FileB.pb

Code: Select all

Enumeration #PB_Event_FirstCustomValue
  #C
  #D
EndEnumeration
MainFile.pb

Code: Select all

XIncludeFile "FileA.pb"
XIncludeFile "FileB.pb"

Debug #A
Debug #B
Debug #C ;same as #A
Debug #D ;same as #B
macOS Catalina 10.15.7
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Enumeration #PB_Event_FirstCustomValue

Post by Josh »

Like the name says, it is the first custom value :mrgreen:


Try following:

Code: Select all

Enumeration MyEnumName #PB_Event_FirstCustomValue
  #A
  #B
EndEnumeration

Code: Select all

Enumeration MyEnumName
  #C
  #D
EndEnumeration

Maybe its a better way to write a dummy-enumeration in the mainfile and use clean named enums in the includefiles. With this, you will never have a problem if the order of the include-files is changing.:

Code: Select all

Enumeration MyEnumName #PB_Event_FirstCustomValue
EndEnumeration

Code: Select all

Enumeration MyEnumName
  #A
  #B
EndEnumeration

Code: Select all

Enumeration MyEnumName
  #C
  #D
EndEnumeration
sorry for my bad english
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Enumeration #PB_Event_FirstCustomValue

Post by ts-soft »

Here an example with modules!

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
This is the first defined includefile.

Use for all modules, that require some of constants:

Code: Select all

UseModule CommonConstants
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
Post Reply