The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: korte on April 12, 2007, 07:53:36 PM

Title: Remove bracket
Post by: korte on April 12, 2007, 07:53:36 PM
How to remove "(" and ")" character in macro output

calling macro:

testmac (anything,something)


want output:
anything,something



Title: Re: Remove bracket
Post by: PBrennick on April 12, 2007, 10:02:53 PM
korte,
Unless you are doing something that I am unaware of, the parenthesis has no effect on the output. For example, if I have the following macro:


txt MACRO Text:VARARG
    LOCAL dbText

    .DATA
      dbText BYTE Text,0
    .CODE
      ExitM < offset dbText >
    ENDM


... and I invoke it in the following manner:


    mov     [esi].lpszText, txt("New Project")


The output is New Project, without any parenthesis or quotation marks.

HTH,

Paul
Title: Re: Remove bracket
Post by: korte on April 13, 2007, 05:41:24 AM
The problem

  testmac (xxx,yyy)


testmac macro text:vararg
.
.

  invoke text

Title: Re: Remove bracket
Post by: Tedd on April 14, 2007, 04:31:48 PM
testmac xxx,yyy

?
Title: Re: Remove bracket
Post by: korte on April 15, 2007, 05:31:48 PM
NO.

I want call macro C style

CreateWindow(0,0,0,0,0,0)


CreateWindow is macro. i want convert "(" and ")" to space or skip.
Title: Re: Remove bracket
Post by: Jimg on April 15, 2007, 10:29:53 PM
use substr
Title: Re: Remove bracket
Post by: korte on April 16, 2007, 09:54:34 AM
God idea, :clap:
But not work  :'(



testmac macro p1,p2
   %echo parameter 1: p1
   %echo parameter 2: p2
   endm


removebracket macro text:VARARG
   tlen textequ @SizeStr(<text>)
   nobracket SubStr <text>,2,tlen-2
   exitm <nobracket>
   endm


   testmac removebracket (123,456)



Problem: testmac only 1 parameter "123,456"
The "123,456" string non break 2 parameter "123" and "456"  :(

Title: Re: Remove bracket
Post by: MichaelW on April 16, 2007, 10:39:12 AM
For a macro function, the argument list must be enclosed in "parenthesis", and the parenthesis will not be treated as part of the arguments. A macro function differs from a macro procedure in that it returns a value using the EXITM directive.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    testmac1 macro p1,p2
      %echo parameter 1: p1
      %echo parameter 2: p2
    endm

    testmac2 macro p1,p2
      %echo parameter 1: p1
      %echo parameter 2: p2
      exitm <eax>
    endm

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    testmac1(123,456)
    testmac2(123,456)
   
    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


parameter 1: (123
parameter 2: 456)
parameter 1: 123
parameter 2: 456


Is this what you are wanting to do?
Title: Re: Remove bracket
Post by: korte on April 16, 2007, 10:47:54 AM
No!


testmac2 macro p1,p2
      %echo parameter 1: p1
      %echo parameter 2: p2
    endm

testmac2 (123,456)


Output is:
parameter 1: (123
parameter 2: 456)


Title: Re: Remove bracket
Post by: korte on April 16, 2007, 10:49:50 AM
 :bg :bg :bg

work. Thanks




    testmac2 macro p1,p2
      %echo parameter 1: p1
      %echo parameter 2: p2
      exitm <>
    endm