News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Problem with CatStr macro

Started by jdoe, February 13, 2007, 10:11:11 PM

Previous topic - Next topic

jdoe

Hi,

I don't know much about masm macros but I tried and I can't get it to work. What is my mistake in the code below or I should say first... is it possible ?


MENUCREATE MACRO MenuCount:REQ
   LOCAL count
   count = 1
   WHILE count LE MenuCount
       add edi, 1
       invoke InsertMenuA, esi, %count, MF_STRING, edi, addr @CATSTR(<szMenu>,%count)
       test eax, eax
       jz No_Menu_Added
       count = count + 1
   ENDM
ENDM



The output I'm looking for is...


add edi, 1
invoke InsertMenuA, esi, 1, MF_STRING, edi, addr szMenu1
test eax, eax
jz No_Menu_Added

add edi, 1
invoke InsertMenuA, esi, 2, MF_STRING, edi, addr szMenu2
test eax, eax
jz No_Menu_Added

...




Thanks

MichaelW

The function form of CATSTR is @CatStr. I believe this statement is correct:

invoke InsertMenuA, esi, count, MF_STRING, edi, @CatStr(<addr szMenu>,%count)

Why not automate it further? You could, for example, pass the item string and have the macro add it to the data section.
eschew obfuscation

jdoe

Thanks Michael. Problem solved.

:U