The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on January 28, 2008, 01:49:57 PM

Title: remove
Post by: ragdog on January 28, 2008, 01:49:57 PM
hi

i have a question to remove all 0 from string

example string: 00012345 to 12345



             invoke GetDlgItemText,hWnd,1001,addr lpBuffer,9

             xor esi,esi
             mov ebx,offset lpBuffer
         @@:
             cmp BYTE PTR [ebx],"0"
             jnz @out
             inc ebx
             inc esi
             cmp esi,8
             jnz @B
             
             invoke MessageBox,hWnd,addr lpBuffer,0,MB_OK     
        @out:



greets
ragdog
Title: Re: remove
Post by: Tedd on January 28, 2008, 02:07:49 PM

    invoke GetDlgItemText,hWnd,1001,addr lpBuffer,9

    xor esi,esi
    mov ebx,offset lpBuffer
  @@:
    cmp BYTE PTR [ebx],"0"
    jnz @out
    inc ebx
    inc esi
    cmp esi,8
    jnz @B
;small problem if the whole string was only "0" - will get here, but ebx will point 'after' the string.
;you should maybe also check for the terminating-null ;)
  @out:
    invoke MessageBox,hWnd,ebx,0,MB_OK

Title: Re: remove
Post by: ragdog on January 28, 2008, 03:17:36 PM
thanks for you reply

its a error

example: ist the buffer 00000123

print: 12300000123




Title: Re: remove
Post by: evlncrn8 on January 28, 2008, 04:49:37 PM
sounds like a dirty buffer... debug it and see whats happening?
Title: Re: remove
Post by: ragdog on January 28, 2008, 04:52:39 PM
this problem is solved
thanks