News:

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

Problem with input macro

Started by MichaelW, January 15, 2005, 08:53:52 AM

Previous topic - Next topic

MichaelW

The input macro has a problem with a missing null terminator on the txt db prompt statement. The problem becomes apparent when an instance of the macro is called in a loop and, after the first call, whatever happens to be in the buffer string appears at the end of the prompt.
eschew obfuscation

hutch--

Michael,

Thanks for posting this one, I could duplicate the problem with the following code.


main proc

    LOCAL lpstring  :DWORD
    LOCAL cnt   :DWORD

    mov cnt, 3

    cls
    print "Input Test"
    print chr$(13,10,0)

  @@:

    mov lpstring, input("Type text here : ")
    print lpstring
    print chr$(13,10,0)

    sub cnt, 1
    jnz @B

    exit

main endp


I changed the input macro only by appending a zero on the txt variable.


        .data
          txt db prompt, 0
          buffer db 128 dup (0)
          align 4
        .code


It seems to work correctly now.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php