Any way to do this ? quoted text & function in an argument

Started by Rainstorm, March 13, 2008, 07:59:28 AM

Previous topic - Next topic

Rainstorm

Hi.

was wondering whether there is a way to use Quoted text & something like ustr$(var) in the same argument in a call.

for example in the Messagebox function if I wanted to say The value is ustr$(var)

fn MessageBox, NULL, "The value is" ustr$(var20),addr tittle ,MB_OK

I know the above is wrong, but is there a way to do something like that ?

ToutEnMasm

Hello,
you must used the lstrcat function.This one return the adress of the new chain.
Quote
   invoke MessageBox,NULL,FUNC(lstrcat,addr asciichain,addr asciichain),TEXT("Titre"),MB_OK

jj2007

Here is a variant.

.nolist
include \masm32\include\masm32rt.inc
.data
asciichain db "The value is ",0

.code

start:
invoke MessageBox, NULL,FUNC(lstrcat, addr asciichain, str$(123)),chr$("Title"),MB_OK
invoke MessageBox, NULL, cat$(chr$("The value is "), str$(123)),chr$("Title"),MB_OK
exit
end start

MichaelW

Another variant:

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

    ; ------------------------------------------------------------
    ; This macro is a wrapper for the cat$ macro that allocates a
    ; dedicated buffer on the first call. Because the buffer is
    ; reused for later calls, and because cat$ starts at the first
    ; null it finds, before the buffer is passed to cat$ the first
    ; byte must be set to null. And because there is only a single
    ; buffer, if this macro is called more than once in an invoke
    ; statement, all calls will effectively return the buffer for
    ; the last call.
    ; ------------------------------------------------------------   

    catbuf MACRO arguments:VARARG
      IFNDEF _catbuf_buffer_
        .data?
          _catbuf_buffer_ db 128 dup(?)
        .code
      ENDIF
      nops 3
      mov _catbuf_buffer_, 0
      EXITM cat$(ADDR _catbuf_buffer_, arguments)
    ENDM

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    mov ebx, 12345678h

    MsgBox 0, catbuf("The value is ",uhex$(ebx),"h   "), "Result", 0

    invoke MessageBox, 0, catbuf("The value is ",ustr$(ebx),"   "),
                      chr$("Result"), 0

    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


Edit: The nops 3 was added during my testing so I could easily find the code in a disassembly and verify that the macro was doing what I expected, and I forgot to remove it before I posted.
eschew obfuscation

Rainstorm

ToutEnMasm, jj2007, Michael.......thanks for the replies & examples   :U