News:

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

Echo, macros and the expansion operator %

Started by jj2007, July 27, 2011, 08:48:39 PM

Previous topic - Next topic

jj2007

Just a little snippet demonstrating what the expansion operator % does:

include \masm32\include\masm32rt.inc

MBox MACRO pText, pTitle, MB_x
   invoke MessageBox, 0, reparg(pText), reparg(pTitle), MB_x
   EXITM <eax>
ENDM

IsOK MACRO args:VARARG
  cmp args, IDOK
  EXITM <Zero?>
ENDM

.code
start:
   TestCase=1
   if TestCase eq 0
      
; use echo to see the output of a macro - creates no code
      echo IsOK(MBox ("Hello World", "This is Masm32", MB_OKCANCEL))
   elseif TestCase eq 1
      
; echo with expansion operator - creates code
      % echo IsOK(MBox ("Hello World", "This is Masm32", MB_OKCANCEL))
   else
      
; the real thing
      .if IsOK(MBox ("Hello World", "This is Masm32", MB_OKCANCEL))
         MsgBox 0, "That was OK", "Hi", MB_OK
      .else
         MsgBox 0, "That was NOT OK", "Hi", MB_OK
      .endif
   endif
   exit

end start