News:

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

General question about strings

Started by brixton, September 26, 2005, 08:42:38 AM

Previous topic - Next topic

brixton

Hi all,

I am working on something which uses the OpenFileDialog function.  It says:

QuoteReturn Value
The return value in EAX is the offset of a dedicated 260 byte buffer for this procedure. If the user selects a file name it will be written to the buffer, if the user cancels the dialog, the first byte in the buffer is set to ascii zero.

That would mean that the value in  EAX is a pointer to a buffer?  Now, if I wanted to move, for example, the first character of that buffer (first byte) into another buffer, how would I do it?  I'd assume with BYTE ptr but I can't get it to work (I keep getting errors).

Also then, how could I move the next character after that, and add it to the buffer again (without erasing the first character?).

Thanks in advance!
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

brixton

Hmm ok, I did it a messy way:

    invoke lstrlen, pathpointer
    mov ebx, eax
    sub ebx, 9
    invoke szLeft, pathpointer, ADDR pathbuffer, ebx


It works but there must be a better way of moving the first x amount of characters from one buffer to another!
If you love somebody, set them free.
If they return, they were always yours. If they don't, they never were..

Mirno

I think this should work.

push esi
push edi

mov  esi, src   ; In your case pathpointer
mov  edi, dst   ; In your case OFFSET pathbuffer
                ; or if path buffer is LOCAL
                ; lea edi, pathbuffer
mov  ecx, count ; In your case 9
rep  movsb

pop  edi
pop  esi


Note that if you want to transfer DWORDs (for speed) shift the count down by 2 (add 3 to it first to round up), and use "rep movsd".

Mirno