Hello all,
Could someone inform me on what the point of a 'Named enumeration' is exactly? the documentation is a little vague.
Named enumeration
Re: Named enumeration
Hi Inner,
you can create constants on different locations (mainfile, includefiles, ...) and you get always a unique constant, which is helpful with windows and gadgets
If you work with modules you have to place the enumerations in the declaremodule section to be unique. Inside a Module the naming does not work
In one sentence: Enumerations with the same name are continued:
you can create constants on different locations (mainfile, includefiles, ...) and you get always a unique constant, which is helpful with windows and gadgets
If you work with modules you have to place the enumerations in the declaremodule section to be unique. Inside a Module the naming does not work
In one sentence: Enumerations with the same name are continued:
Code: Select all
Enumeration EGadget
#GadgetInfo ; will be 0
#GadgetText ; will be 1
#GadgetOK ; will be 2
EndEnumeration
Debug "#GadgetInfo = " + #GadgetInfo ; will be 0
Enumeration EGadget ;' same name con
#GadgetHelpInfo ; will be 3
#GadgetHelpText ; will be 4
#GadgetHelpOK ; will be 5
EndEnumeration
Debug "#GadgetHelpInfo = " + #GadgetHelpInfo ; will be 3
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 11 Home
Re: Named enumeration
Inner wrote:...what the point of a 'Named enumeration' is exactly?
Code: Select all
Enumeration windows
#window1 ;starts a new enumeration from 0
#window2
#window3
EndEnumeration
Enumeration gadgets
#gadget1 ;starts a new enumeration from 0
#gadget2
#gadget3
EndEnumeration
Enumeration images
#image1 = 3 ;starts this enumeration from 3
#image2
#image3
EndEnumeration
Enumeration windows
#window4 ;continues from the last "windows" number
EndEnumeration
Enumeration
#gadget4 ;starts a new enumeration from 0
EndEnumeration
Enumeration images
#image4 ;continues from the last "images" number
EndEnumeration
Debug #window1 ;0
Debug #window2 ;1
Debug #window3 ;2
Debug #window4 ;3
Debug #CR$
Debug #gadget1 ;0
Debug #gadget2 ;1
Debug #gadget3 ;2
Debug #gadget4 ;0
Debug #CR$
Debug #image1 ;3
Debug #image2 ;4
Debug #image3 ;5
Debug #image4 ;6
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
Re: Named enumeration
Ahuh! thanks guys, appreciate the knowledge.
Re: Named enumeration
Long time I didn't know for what I should use this, but ...
If you have many pbi files which can be used in different projects and they include PostEvent()
with own events, then it make sense to use the name, so that every pbi extends the enumeration,
so you can still use the names of the constants without thinking about double numbers.
If you have many pbi files which can be used in different projects and they include PostEvent()
with own events, then it make sense to use the name, so that every pbi extends the enumeration,
so you can still use the names of the constants without thinking about double numbers.
Re: Named enumeration
Here a Example:
Serves as a replacement for #PB_Any
Code: Select all
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
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.
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.