Enumeration in Modules
Posted: Fri Aug 26, 2016 4:57 pm
Greetings to all, here's my code:
I was expecting Porche::#c to be 5, but it is 2 nevertheless. What am I doing wrong? I am trying to use this feature for a project where I'd avoid global "Enumeration" file, so I can simply input new enumerations in each separate file without any issues.
I've (sort of, since I'd like to use :: syntax for my enumerations, which would be super fantastic for code readability!) here -> http://www.forums.purebasic.com/english ... 87#p424695 but I'm still wondering what's wrong with my code.
BTW, if i "hardcode" a number after enumeration, it works as expected. So I guess this has nothing to do with modules but with a fact you can't assign variable to enumeration, right?
:punishing myself for being stupid:
#PB_Compiler_EnumerationValue solved my problem, as it seems, by putting it directly after Enumeration... Do'h!

Code: Select all
DeclareModule Cars
Global.i LastEnumeration = 0
EndDeclareModule
Module Cars
EndModule
DeclareModule Ferrari
UseModule Cars
Debug LastEnumeration
Enumeration LastEnumeration
#a
#b
#c
EndEnumeration
EndDeclareModule
Module Ferrari
LastEnumeration + #PB_Compiler_EnumerationValue
Debug "Ferrari " + Str(LastEnumeration)
EndModule
DeclareModule Porche
UseModule Cars
Debug LastEnumeration
Enumeration LastEnumeration
#a
#b
#c
EndEnumeration
EndDeclareModule
Module Porche
LastEnumeration + #PB_Compiler_EnumerationValue
Debug "Porche " + Str(LastEnumeration)
EndModule
Debug Ferrari::#a
Debug Porche::#cI've (sort of, since I'd like to use :: syntax for my enumerations, which would be super fantastic for code readability!) here -> http://www.forums.purebasic.com/english ... 87#p424695 but I'm still wondering what's wrong with my code.
BTW, if i "hardcode" a number after enumeration, it works as expected. So I guess this has nothing to do with modules but with a fact you can't assign variable to enumeration, right?
:punishing myself for being stupid:
Code: Select all
DeclareModule Ferrari
Enumeration #PB_Compiler_EnumerationValue
#a
#b
#c
EndEnumeration
EndDeclareModule
Module Ferrari : EndModule
DeclareModule Porche
Enumeration #PB_Compiler_EnumerationValue
#a
#b
#c
EndEnumeration
EndDeclareModule
Module Porche : EndModule
Debug Ferrari::#a
Debug Porche::#c