Hi all,
1) How to find a word in a line and then make a condition jump?
invoke SendMessage, hEdit, EM_EXGETSEL, 1, addr Cr
I want to search the hEdit word in THAT line (not whole content) and if found it, make a jump to some where. Any example code?

2) What is the code for eof (end of file)? eg VK_BACK is 08h.

Posted on 2004-02-15 07:27:16 by QS_Ong
1) Since you have the strnig you can manually search for the word in the string. It is not that hard

2) Since when is there a eof to mark the end of file?
Posted on 2004-02-15 08:21:31 by roticv
not exactly sure if MASM syntax is right.

mov esi,"address of your word"
mov edi,"address of line to search"
mov ecx,"word number to scan"
rep cmpsw ; this one

you can do "scasb" or "cmpsb" for byte searches

just an idea
Posted on 2004-02-15 10:37:07 by mrgone

ifIsChar macro what ; I use it to detect masm possible words
.if what=="$" || (what>="@" && what<="Z") || what=="_" || (what>="a" && what<="z") || (what>="0" && what<="9")

FindWord proc uses ebx esi edi Where,What
mov esi,Where
mov edi,What
cmp byte ptr[edi],0
je _ret
mov al,[esi]
mov bl,[edi]
.if !bl
ifIsChar al
jmp _notmatch
mov edx,edi
sub edx,What
sub edx,esi
neg edx
mov al,[edx-1]
movzx eax,al
ifIsChar al
jmp _notmatch
jmp _good
or al,al
jz _ret
inc esi
inc edi
.if al!=bl
sub edi,What
sub esi,edi
mov edi,What
inc esi
jmp _again
sub edi,What
sub esi,Where
sub esi,edi
mov eax,esi
inc eax
_ret: xor eax,eax
FindWord endp

[color=blue]IsMyWordOnThisLine[/color] proc hEdit,MyWord
local ThisLine[256]:byte
mov ax,255
mov ThisLine[0],al
mov ThisLine[1],ah
invoke SendMessage,hEdit,EM_LINEFROMCHAR,[color=red]-1[/color],0 ; number of line is in red, -1 means "current line"
invoke SendMessage,hEdit,EM_GETLINE,eax,addr ThisLine
mov ThisLine[eax],0
invoke FindWord,addr ThisLine,MyWord
.if eax [color=green]; yep, here's the word[/color]
; do what you want
[color=blue]IsMyWordOnThisLine[/color] endp


There is no such thing as eof in Win32 API. You need a simple wrapper to see if you're at the eof position. Probably you should use

invoke SetFilePointer,file1,0,0,FILE_CURRENT
push eax
invoke GetFileSize,file1,0
pop edx
.if eax==edx
; we're at the end of file

This is the simplest and most ineffective way to do this. I personally would use OOP here.
Posted on 2004-02-15 15:27:07 by Ultrano
Hi all,
Thank for your help.
Some more Questions.

1) How to determine the character or word before or after the caret?
eg in richedit control
invoke SendMessage, hEdit,EM_REPLACESEL,TRUE,ADDR CR
when the caret is in between "hEdit," and "EM_REPLACESEL", how to determine that before the caret is "," or "hEdit," and after the caret is "E" or "EM_REPLACESEL". If I use EM_GETLINE I can't determine the location of caret.

2) How to know that the caret is in the end of the file. (That mean no other word after the caret)

Thanks a lot.
Posted on 2004-02-18 08:26:32 by QS_Ong