For positive and negative series...
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/flag for later use.
; 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
Debug "-- Positive Constants/Flags --"
ENUM_RESET(0)
ENUM_x2(0,BIT) : Debug "#bit0 = " + #bit0
ENUM_x2(1,BIT) : Debug "#bit1 = " + #bit1
ENUM_x2(2,BIT) : Debug "#bit2 = " + #bit2
ENUM_x2(3,BIT) : Debug "#bit3 = " + #bit3
ENUM_x2(4,BIT) : Debug "#bit4 = " + #bit4
ENUM_x2(5,BIT) : Debug "#bit5 = " + #bit5
ENUM_x2(6,BIT) : Debug "#bit6 = " + #bit6
ENUM_x2(7,BIT) : Debug "#bit7 = " + #bit7
Debug "-- Negative Constants/Flags --"
ENUM_RESET(0)
ENUM_x2(0,BITn,1) : Debug "#bitn0 = " + #bitn0
ENUM_x2(1,BITn,1) : Debug "#bitn1 = " + #bitn1
ENUM_x2(2,BITn,1) : Debug "#bitn2 = " + #bitn2
ENUM_x2(3,BITn,1) : Debug "#bitn3 = " + #bitn3
ENUM_x2(4,BITn,1) : Debug "#bitn4 = " + #bitn4
ENUM_x2(5,BITn,1) : Debug "#bitn5 = " + #bitn5
ENUM_x2(6,BITn,1) : Debug "#bitn6 = " + #bitn6
ENUM_x2(7,BITn,1) : Debug "#bitn7 = " + #bitn7
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum