Hi all,
1) How to find a word in a line and then make a condition jump?
eg:
...
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.
TQ
1) How to find a word in a line and then make a condition jump?
eg:
...
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.
TQ
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?
2) Since when is there a eof to mark the end of file?
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
jz
you can do "scasb" or "cmpsb" for byte searches
just an idea
mov esi,"address of your word"
mov edi,"address of line to search"
mov ecx,"word number to scan"
rep cmpsw ; this one
jz
you can do "scasb" or "cmpsb" for byte searches
just an idea
1)
2)
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
This is the simplest and most ineffective way to do this. I personally would use OOP here.
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")
endm
FindWord proc uses ebx esi edi Where,What
mov esi,Where
mov edi,What
cmp byte ptr[edi],0
je _ret
_again:
mov al,[esi]
mov bl,[edi]
.if !bl
ifIsChar al
jmp _notmatch
.endif
mov edx,edi
sub edx,What
sub edx,esi
neg edx
mov al,[edx-1]
movzx eax,al
ifIsChar al
jmp _notmatch
.endif
jmp _good
.endif
or al,al
jz _ret
inc esi
inc edi
.if al!=bl
_notmatch:
sub edi,What
sub esi,edi
mov edi,What
inc esi
.endif
jmp _again
_good:
sub edi,What
sub esi,Where
sub esi,edi
mov eax,esi
inc eax
ret
_ret: xor eax,eax
ret
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
.endif
ret
[color=blue]IsMyWordOnThisLine[/color] endp
2)
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
.endif
This is the simplest and most ineffective way to do this. I personally would use OOP here.
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.
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.