i have a multiline string i need parsed. here is a sample of what it looks like.
data db "dr-xr-xr-x   1 owner    group       0 May 21  2001 deskapps",13,10,

"dr-xr-xr-x 1 owner group 0 Apr 20 2001 developr",0

whats making this kinda tough is that i need different parts of the string at differnt times when processing it. for example on line one i need to have deskapps first and add it to my listview then get some other parts of the string and add it to my listview. adding it to my listview isnt a problem. ihere is my attempt and it works ok but i was wondering if someone can demonstrate a better way. in the example i have stored the parts temporarly into variables dat1-data5.
         xor ecx,ecx

xor edi,edi
mov esi, data
Restart:
lea edi, data1
@@:
cmp al,0
je @E
mov al,[esi]
inc esi
mov [edi],al
inc edi
cmp al,20h
jne @B
mov byte ptr [edi], 0
@@:
mov al,[esi]
inc esi
cmp al,20h
je @B
dec esi
dec edi
mov byte ptr [edi], 0
@@:
mov al,[esi]
inc esi
cmp al,20h
jne @B
@@:
mov al,[esi]
inc esi
cmp al,20h
je @B
dec esi
dec edi
lea edi, data2
@@:
mov al,[esi]
inc esi
mov [edi],al
inc edi
cmp al,20h
jne @B
mov byte ptr [edi], 0
@@:
mov al,[esi]
inc esi
cmp al,20h
je @B
dec esi
dec edi
lea edi, data3
@@:
mov al,[esi]
inc esi
mov [edi],al
inc edi
cmp al,20h
jne @B
mov byte ptr [edi], 0
@@:
mov al,[esi]
inc esi
cmp al,20h
je @B
dec esi
dec edi
lea edi, data4
@@:
mov al,[esi]
inc esi
mov [edi],al
inc edi
cmp al,20h
jne @B
mov byte ptr [edi], 0
;///problem
@@:
mov al,[esi]
inc esi
cmp al,20h
je @B
dec esi
dec edi
lea edi, data5
@@:
mov al,[esi]
inc esi
mov [edi],al
inc edi
cmp al,20h
jne @B

@@:
mov al,[esi]
inc esi
mov [edi],al
inc edi
cmp al,20h
je @B

@@:
mov al,[esi]
inc esi
mov [edi],al
inc edi
cmp al,20h
jne @B

@@:
mov al,[esi]
inc esi
mov [edi],al
inc edi
cmp al,20h
je @B

@@:
mov al,[esi]
inc esi
mov [edi],al
inc edi
cmp al,20h
jne @B
mov byte ptr [edi], 0

@@:
mov al,[esi]
inc esi
cmp al,20h
je @B
dec esi
dec edi
lea edi, data6
@@:
mov al,[esi]
inc esi
mov [edi],al
inc edi
cmp al,0
je @Z
cmp al,13
jne @B
mov byte ptr [edi-1], 0
@Z:
invoke AddDir,addr data6
invoke AddSubItem,addr data1,3
invoke AddSubItem,addr data2,4
invoke AddSubItem,addr data3,5
invoke AddSubItem,addr data4,1
invoke AddSubItem,addr data5,2
inc esi
inc edi
jmp Restart
@E:

just a small picture to show you what sections i need parsed.
Posted on 2002-05-08 19:28:46 by smurf
Here is my version of your problem. Im assuming that the "data" will be formated much like how you have it indicated. Where everything is 'columnized' and only the last DIR name will vary in length.
.386

.model flat,stdcall
option casemap:none

ParseString PROTO :DWORD

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

PData STRUC
data1 db 15 dup(?) ;dr-xr-xr-x...1.
data2 db 9 dup(?) ;owner....
data3 db 12 dup(?) ;group.......
data4 db 2 dup(?) ;0.
data5 db 13 dup(?) ;May.21..2001.
data6 db 1 dup(?) ;deskapps. (null always fixed at last char)
PData ENDS

; NOTE: '.' == NULL's
; '|' == Data field start
; '-' == Data
;
.data ; 13 bytes 9 bytes 12 bytes 13 bytes What ever amount
;|---------...-.|----....|----.......|-------------.|------->. ?
Data db "dr-xr-xr-x 1 owner group 0 May 21 2001 deskapps",13,10,
"dr-xr-xr-x 1 owner group 0 Apr 20 2001 developr",0

.code
start:

invoke ParseString, addr Data
invoke ExitProcess, NULL

; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ParseString PROC USES ESI EDI EBX lpStringIn:DWORD
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
LOCAL buffer[256] :BYTE ; Buffer to hold up to NULL or 13
LOCAL Flag13 :DWORD ; Addr Flag to indicate "more"

mov esi, lpStringIn ; ESI == Get the source address
StartAgain:
lea edi, buffer ; EDI == BUFFER
xor eax, eax ; EAX == 0
mov Flag13, eax ; Initialize Flag
@Back:
mov al, [esi] ; EAX == 000000XX h
mov [edi], al ; Copy it to buffer
cmp eax, NULL ; ? EAX == 0
je @Done ; yes, next stage
cmp eax, 13 ; ? EAX == 13
je @Done13 ; Yes, to 13 stuff
cmp eax, 20h ; ? EAX == SPACE?
jne @F ; No, skip this
mov BYTE PTR [edi], NULL ; Yes, then really write NULL
@@:
inc esi ; Next char
inc edi ; Next Dest
jmp @Back
@Done13:
add esi, 2 ; Skip 13,10 (2 bytes)
mov Flag13, esi ; mov Flag13 addr Next start
@Done:
lea ebx, buffer ; ESI == BUFFER
mov BYTE PTR [edi],NULL ; Write byte over NULL/13
lea esi, [ebx].PData.data5 ; Get the addr to the "problem"
xor edi, edi ; EDI == NULL
.while( edi < 12 ) ; Upto but not including the NULL
mov al, [esi] ; Get char in al
cmp eax, NULL ; see if NULL
jne @F ; No, next
mov BYTE PTR [esi], 20h ; Yes, fix it with space
@@:
inc esi ; next char
inc edi ; count++
.endw

; invoke AddDir,addr [ebx].PData.data6
; invoke AddSubItem,addr [ebx].PData.data1,3
; invoke AddSubItem,addr [ebx].PData.data2,4
; invoke AddSubItem,addr [ebx].PData.data3,5
; invoke AddSubItem,addr [ebx].PData.data4,1
; invoke AddSubItem,addr [ebx].PData.data5,2

invoke MessageBox, NULL, addr [ebx].PData.data1, NULL, MB_OK
invoke MessageBox, NULL, addr [ebx].PData.data2, NULL, MB_OK
invoke MessageBox, NULL, addr [ebx].PData.data3, NULL, MB_OK
invoke MessageBox, NULL, addr [ebx].PData.data4, NULL, MB_OK
invoke MessageBox, NULL, addr [ebx].PData.data5, NULL, MB_OK
invoke MessageBox, NULL, addr [ebx].PData.data6, NULL, MB_OK

cmp Flag13, NULL ; See if Address was noted
je @F ; No, leave
mov esi, Flag13 ; yes, move it into esi
jmp StartAgain ; Do it all again!
@@:
ret
ParseString ENDP
; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
end start
end


The comments should be pretty clrear whats going on. But in short, Copy the string to buffer (to keep source unchanged), run through and replace *ALL* spaces with NULL. Then look up the "date problem" and fix back all NULL's to spaces ~ except the last char in the field. Lastly, apply a structure over the buffer as a mask to look up starting addresses for the data.

Enjoy, I Hope you like,
:alright:
NaN
Posted on 2002-05-09 03:07:14 by NaN
unfortunatly i should have been more specific about what i needed. the spaces, and text lengths are of different sizes when i use them. this was just an example of what it looks like for the most part. thank you for the time you spent though. i hope you dont think you wasted too much time i did learn a few things from your code.
Posted on 2002-05-10 01:40:39 by smurf
i did learn a few things from your code.

Glad to hear it ;)

There is other ways too, but its late, i will see what i can do tomorrow.

:alright:
NaN
Posted on 2002-05-10 02:53:42 by NaN