Page 1 of 1

Strings tables

Posted: Sat Jun 15, 2019 3:34 pm
by Olliv
To help mk-soft, after numbers, strings.

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)


Re: Strings tables

Posted: Sat Jun 22, 2019 2:45 pm
by ar-s
Cool and fast. Thanks

Re: Strings tables

Posted: Sat Jun 22, 2019 4:03 pm
by Olliv
Thank you for reply.

This request shows me, that two mistakes are within one of the code lines. Here we cannot build more than... one table.

This line below is false :

Code: Select all

;*****************************************************************************
  DimSH# MacroExpandedCount = DimSLin11 - DimSLin01 - 1
I am stupid. I will correct that. And I will add an other tip to try to be forgiven...

Re: Strings tables

Posted: Sat Jun 22, 2019 4:16 pm
by Olliv
Now, it's ok. But do not forget this example must not to be used to store personnal datas which are not crypted in the final executable file.

This last detail will be the next tip : store datas easily and explain how to crypt them.