Code: Select all
Dim MySettings.s(0)
Macro DoubleQuote
"
EndMacro
Macro DEFc
DEF
EndMacro
Macro AULTc
AULT
EndMacro
Macro InitSettings(SetName) ; creates a constant, adds one to MySettings array size, and fills it with the text.
ReDim MySettings(#PB_Compiler_EnumerationValue)
Enumeration #PB_Compiler_EnumerationValue
#SETTING_#SetName
EndEnumeration
MySettings(#SETTING_#SetName) = DoubleQuote#SetName#DoubleQuote
EndMacro
InitSettings(DEFc#AULTc) ; <--- makes just this ONE word, DEFAULT all caps
InitSettings(SET_ONE)
InitSettings(SET_TWO)
Debug MySettings(0) ; Prints string in all caps
Debug #SETTING_DEFAULT ; All constants are defined with all caps, too.
Debug MySettings(1)
Debug #SETTING_SET_ONE
Debug MySettings(2)
Debug #SETTING_SET_TWO
And I think it may be posted elsewhere, but just in case it is not, this is also a method to cleanly initialize an array without the dreaded data + read loop. I have not measured the cost of the ReDim (in terms of speed) but since there is no loop, it can't be too bad. This method works great when you have numerous settings to deal with, and avoids typing an Enumeration and Data, and hope they stay synchronized.