Page 1 of 1
Named enumeration
Posted: Wed Mar 31, 2021 11:15 am
by Inner
Hello all,
Could someone inform me on what the point of a 'Named enumeration' is exactly? the documentation is a little vague.
Re: Named enumeration
Posted: Wed Mar 31, 2021 11:46 am
by Axolotl
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:
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
Re: Named enumeration
Posted: Wed Mar 31, 2021 11:52 am
by TI-994A
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
Re: Named enumeration
Posted: Wed Mar 31, 2021 12:06 pm
by Inner
Ahuh! thanks guys, appreciate the knowledge.
Re: Named enumeration
Posted: Wed Mar 31, 2021 12:11 pm
by infratec
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.
Re: Named enumeration
Posted: Wed Mar 31, 2021 5:44 pm
by ts-soft
Here a Example:
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
Serves as a replacement for #PB_Any