String tables
Caution : strings are NOT PROTECTED in an executable, even with single op xor.
Code: Select all
;*********************************************************************************************************************
Macro Table
Define.I DimSLin0# MacroExpandedCount = #PB_Compiler_Line
DataSection
DimSData# MacroExpandedCount:
Data.S ""
EndMacro
Macro EndTable(ArrName)
DimSEndD# MacroExpandedCount:
EndDataSection
Define.I DimSLin1# MacroExpandedCount = #PB_Compiler_Line
DimSTotal# MacroExpandedCount = 0
For DimSI# MacroExpandedCount = ?DimSData# MacroExpandedCount To ?DimSEndD# MacroExpandedCount Step 2
If PeekW(DimSI# MacroExpandedCount) = 0
DimSTotal# MacroExpandedCount + 1
EndIf
Next
DimSH# MacroExpandedCount = DimSLin1# MacroExpandedCount - DimSLin0# MacroExpandedCount - 1
If DimSH# MacroExpandedCount
DimSL# MacroExpandedCount = DimSTotal# MacroExpandedCount / DimSH# MacroExpandedCount
DimSL# MacroExpandedCount - 1
DimSH# MacroExpandedCount - 1
Global Dim ArrName.S(DimSL# MacroExpandedCount, DimSH# MacroExpandedCount)
Restore DimSData# MacroExpandedCount
For DimSI# MacroExpandedCount = 0 To DimSH# MacroExpandedCount
For DimSJ# MacroExpandedCount = 0 To DimSL# MacroExpandedCount
Read.S ArrName(DimSJ# MacroExpandedCount, DimSI# MacroExpandedCount)
Next
Next
EndIf
EndMacro
;- Example
Table+
"red", "magenta",
"green", "cyan",
"blue", "yellow"
EndTable(Cool)
Debug Cool(1, 2)