i an editbox when text is typed in i want to be able to search individual lines. right now i can process the first line typed into the editbox. basically im looking for the end of line(carriage return). once i find it i popup a messagebox with the text that is on that line. problem is that i cant continue on to the next lines and process each line the same exact way and popup a messagebox etc. somoene wanna help me out with this?
Posted on 2002-01-13 13:28:19 by smurf
Once again I see no terminating zero for the buffer1.
But all you have to do is basically remember where you stopped searching for the 13, increase it by one and continue scanning buffer1 again with the next line until you find another 13 or a 0.

Try this.

GetWindowText.
xor edx,edx
@restart:
lea ecx,
push ecx
pop ebx ;we save it for the MessageBox call
dec ecx
dec edx
@@:
inc ecx
inc edx ;our counter
mov al,byte ptr
cmp al,0 ;EndOf
jz @F
cmp al,13
jnz @B
; Here we found a 13
push ecx
push edx
mov byte ptr ,0 ;we write a terminating 0
invoke MessageBox,0,ebx,0,0 ;ebx contains the addr of the Buffer1
pop edx
pop ecx
mov byte ptr ,13 ;we restore the value
inc edx ;to skip the 13 -edited
jmp @restart
@@:
No more data

Eh, I don't know if this works.. I guess it does... I just wrote it pretty quick while I'm waiting for a download... (*g*) I hope this helps you out tho...

Edit: PS: If your Buffer only holds 512 bytes , try grabbing only 511 bytes with GetWindowText. This way you make sure that the last byte in your Buffer is always a 0.

Edit 2: Corrected 2 lines
Posted on 2002-01-13 14:04:44 by JimmyClif
thank you jimmyclif it works great.

here is the code snipet again with comments. can you tell me if i a good understanding of what is happening in the code.
              xor edx,edx                  ;zero out edx

@@restart:
lea ecx,[buffer0+edx] ;store the full buffer into ecx
push ecx ;store contents of ecx onto the stack
pop ebx ;store contents that were on stack into ebx
dec ecx ;move pointer ecx back one
dec edx ;move counter edx back one
@@back:
inc ecx ;move pointer ecx forward one so we start at position zero now
inc edx ;move counter edx forward one so we start at zero now
mov al,byte ptr [ecx] ;move the character at ecx into al
cmp al,0 ;compare al to see if it is the end of file
jz @@forward ;if it is stop looping and jump over everthing
cmp al,13 ;compare al to end of line
jne @@back ;jump to back if not equal to 13(end of line)
push ecx ;end of line found so now push complete contents onto the stack
push edx ;push the counter onto the stack
mov byte ptr [ecx],0 ;we write a terminating 0
invoke MessageBox,0,ebx,0,0 ;ebx contains the addr of the Buffer1
pop edx
pop ecx
mov byte ptr [ecx],13 ;we restore the value
inc edx ;to skip the 13 -edited
jmp @@restart
@@forward:
Posted on 2002-01-13 18:26:29 by smurf
Yep, you got it all right...

When it jumps back to the @@restart point, we still have the counter in edx and we load the Buffer + the counter into ecx... store it into ebx for the MessageBox call and keep going - as easy as that ;)

Don't forget! On 2k and ME etc.. you have to preserve ebx.. so better push it at the beginning and pop it at the end to make it compatible...

Heh.. btw: Where is Casa Grande? Around Tucson?
Posted on 2002-01-13 19:02:33 by JimmyClif
ok thanks. ;)

well ya its pretty close to tucon. its actually between pheonix and tucon very close to florence where the state prison is.
Posted on 2002-01-13 19:30:16 by smurf