can anyone give me a tip (or tips) on how to create an array of strings (they will be no longer than 64 characters), and be able to access the array with ease? i would like to get around declaring x number of variables to hold the values. thanks.
Posted on 2002-06-27 13:37:47 by freedumb
ok, to avoid "a lot of variables", you should define a label...
Here's a little and simple quick-and-dirty hacky code snippet.
I think this is a good way to do it, although the macro needs
some work, and the example code is silly.



@String MACRO xxx:req
local theStr
CONST segment
theStr db xxx, 0
CONST ends
EXITM <offset theStr>
ENDM
.data
stringTable label DWORD
dd @String("lalala")
dd @String("Second entry")
dd @String("It does seem to work")
dd @String("mmoooooooOooooooooooh")
stringTableEnd LABEL DWORD
.code
ENTRY32:
mov ebx, ((offset stringTableEnd - offset stringTable) / 4) - 1
@@loop:
mov eax, [stringTable + ebx*4]
invoke MessageBox, NULL, eax, eax, MB_OK
dec ebx
jns @@loop
invoke ExitProcess, 0
Posted on 2002-06-27 14:13:06 by f0dder
make each string 64 Bytes by zero padding the sorter ones then use 64*string index to get to each one

EDIT
you beat me f0dder
Posted on 2002-06-27 14:13:32 by Kudos
This is a complex macro (i never bothered to comment it) but it does what you want.



strtbl macro _name:req, _strings:vararg
local @@lbl
$s equ <>
o@=0
_data segment
p_&_name& label byte
irp $v, <_strings>
$l catstr <@@lbl>, %o@
ifidn <$v>, <"">
$l byte 0
else
$l byte $v, 0
endif
$s catstr $s, <,>, $l
o@ = o@ + 1
endm
byte 0
align 4
_name dword @SubStr(<%$s>, 2)
_data ends
endm

.data
strtbl tips, "Cut", "Copy", "Paste", "Undo", "Redo"

tips[0]=addr "Cut", tips[4]=addr "Copy", tips[8]=addr "Paste"...
Posted on 2002-06-27 15:02:30 by gfalen