Code: Select all
Enumeration Binary
#This ; 0
#That ; 1
#TheOther ; 2
#AndOn ; 4
#LikeSo ; 8
EndEnumeration
Code: Select all
Enumeration Binary
#This ; 0
#That ; 1
#TheOther ; 2
#AndOn ; 4
#LikeSo ; 8
EndEnumeration
Code: Select all
Macro BinEnum(var)
Enumeration (#PB_Compiler_EnumerationValue)*2
EndEnumeration
#var=(#PB_Compiler_EnumerationValue)/4
EndMacro
Enumeration 1
EndEnumeration
BinEnum(This)
BinEnum(That)
BinEnum(TheOther)
BinEnum(AndOn)
BinEnum(LikeSo)
Debug #This ; 0
Debug #That ; 1
Debug #TheOther ; 2
Debug #AndOn ; 4
Debug #LikeSo ; 8
Enumeration 1
EndEnumeration
BinEnum(Second)
BinEnum(Bunch)
BinEnum(Now)
BinEnum(Shown)
BinEnum(Here)
Debug #Second ; 0
Debug #Bunch ; 1
Debug #Now ; 2
Debug #Shown ; 4
Debug #Here ; 8
Code: Select all
Macro HASH
#
EndMacro
Macro ENUM_RESET(n=0)
Enumeration n
EndEnumeration
EndMacro
Macro ENUM_x2(n, Name, negative=0)
; Create enumeration constant for later use as an index within array()'s
; Or as a bit flag to compare error fields.
; Positive (0,1,2,4,...) or Negative (0,-1,-2,-4,...) series.
; Enumerations support Long, Not Quad.
CompilerIf #PB_Compiler_EnumerationValue = 0
Enumeration #PB_Compiler_EnumerationValue
HASH#Name#n
CompilerElseIf #PB_Compiler_EnumerationValue = 1
CompilerIf negative
Enumeration #PB_Compiler_EnumerationValue Step -1
HASH#Name#n = -#PB_Compiler_EnumerationValue
CompilerElse
Enumeration #PB_Compiler_EnumerationValue
HASH#Name#n
CompilerEndIf
CompilerElse ; #PB_Compiler_EnumerationValue >= 2
CompilerIf negative
Enumeration #PB_Compiler_EnumerationValue Step -1
HASH#Name#n = (#PB_Compiler_EnumerationValue + 1) * 2
CompilerElse
Enumeration #PB_Compiler_EnumerationValue Step 1
HASH#Name#n = (#PB_Compiler_EnumerationValue - 1) * 2
CompilerEndIf
CompilerEndIf
EndEnumeration
EndMacro
ENUM_RESET(0)
Debug "-- Up --"
ENUM_x2(0, UP, 0): Debug #UP0
ENUM_x2(1, UP, 0): Debug #UP1
ENUM_x2(2, UP, 0): Debug #UP2
ENUM_x2(4, UP, 0): Debug #UP4
ENUM_RESET(0)
Debug "-- Down --"
ENUM_x2(0, DN, 1): Debug #DN0
ENUM_x2(1, DN, 1): Debug #DN1
ENUM_x2(2, DN, 1): Debug #DN2
ENUM_x2(4, DN, 1): Debug #DN4