From: Leo on
on 1/07/2010, Karl E. Peterson supposed :
> Kevin Provance was thinking very hard :
>> "Leo" <ttdhead(a)gmail.com> wrote in message
>> news:i0gq49$u7o$1(a)news.eternal-september.org...
>>>
>>> I would have thaught INSTR would do the trick for finding and using a
>>> module level variable for keeping track of where to start searching
>>> from and maybe one for the search term too check if we it is a new
>>> term/string to search for.
>>
>> Many moons ago I rolled my own Find/Replace which is no longer used in
>> production, but as I never delete anything code wise, I would imagine it's
>> still around someplace and would work great with this project.
>>
>> I guess maybe - considering Karl's events - I would pass the whole text and
>> also pass back the position to highlight using the Find/Replace events.
>> Replace all I would handle all at once with Replace, allowing for case
>> sensitive searches and the like. I guess we would be grateful there isn't
>> pattern matching included.
>>
>> There a bunch of different ways to go here. I have confidence Karl will
>> pick (or rather, write) the best. <g>
>
> It's the "Match whole words only" part where it really gets spooky. <g> I
> remember entering a contest Crescent Software held back in the 80s to see who
> could write the fastest Word Counter app with QuickBasic. OMG, the issues
> come at you fast and furious, and at some point you just have to close your
> eyes and *hope*. <g>
>
> Proposal: Go ahead with Instr, and when you find a match check the character
> before and after to see if it's alpha? Would that cover 99% of the cases?
> Of course, "back in the day", no one used those funky accented upper-ASCII
> things, either.
>
> And if you *really* wanted to write an all-purpose routine, you'd have to
> include full-on Unicode support, too, eh? I have no idea how to define a
> "whole word" in that realm.

I just did a brisk search of the APIs starting with Is and found
IsCharAlphanumeric. Would that help determine a whole word as it uses
the settings set in setup or control pannel?

--
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org


From: Leo on
Leo formulated on Thursday :
> Karl E. Peterson has brought this to us :
>> Leo formulated on Wednesday :
>>> Karl E. Peterson submitted this idea :
>>>> Kevin Provance was thinking very hard :
>>>>> "Leo" <ttdhead(a)gmail.com> wrote in message
>>>>> news:i0gq49$u7o$1(a)news.eternal-september.org...
>>>>>>
>>>>>> I would have thaught INSTR would do the trick for finding and using a
>>>>>> module level variable for keeping track of where to start searching
>>>>>> from and maybe one for the search term too check if we it is a new
>>>>>> term/string to search for.
>>>>>
>>>>> Many moons ago I rolled my own Find/Replace which is no longer used in
>>>>> production, but as I never delete anything code wise, I would imagine
>>>>> it's still around someplace and would work great with this project.
>>>>>
>>>>> I guess maybe - considering Karl's events - I would pass the whole text
>>>>> and also pass back the position to highlight using the Find/Replace
>>>>> events. Replace all I would handle all at once with Replace, allowing
>>>>> for case sensitive searches and the like. I guess we would be grateful
>>>>> there isn't pattern matching included.
>>>>>
>>>>> There a bunch of different ways to go here. I have confidence Karl will
>>>>> pick (or rather, write) the best. <g>
>>>>
>>>> It's the "Match whole words only" part where it really gets spooky. <g>
>>>> I remember entering a contest Crescent Software held back in the 80s to
>>>> see who could write the fastest Word Counter app with QuickBasic. OMG,
>>>> the issues come at you fast and furious, and at some point you just have
>>>> to close your eyes and *hope*. <g>
>>>>
>>>> Proposal: Go ahead with Instr, and when you find a match check the
>>>> character before and after to see if it's alpha? Would that cover 99% of
>>>> the cases? Of course, "back in the day", no one used those funky
>>>> accented upper-ASCII things, either.
>>>>
>>>> And if you *really* wanted to write an all-purpose routine, you'd have to
>>>> include full-on Unicode support, too, eh? I have no idea how to define a
>>>> "whole word" in that realm.
>>>
>>> If I am reading that correctly, then that isn't what wordpad does. If you
>>> say enter 78hello87 into wordpad and search for it, it includes the
>>> numbers as part of the word when "Match whole words only" is checked.
>>
>> Yeah, I'd call those numeric, not alpha. But that's interesting, I'd have
>> to try it to really see what you're saying. OTOH, I'd say you have a hit
>> if it were "hello!", eh?
>
> Nope it doesn't find hello in that string so wordpad in an English locale
> counts numbers as part of a word. But If I add an _ to the begining and a +
> at the end and search for the original string it ignores the two new
> characters.

You could take a look at IsCharacterAlphaNumeric which is language
independant.

--
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org


From: Mayayana on
Wordpad uses a RichEdit window.
You can check the status of characters in
a RichEdit with the following code.
Put an RTB and a label on a form, paste
text into the RTB, then click characters:

Private Const WM_USER = &H400
Private Const EM_FINDWORDBREAK = (WM_USER + 76)
Private Const WB_CLASSIFY As Long = 3
Private Const WBF_BREAKAFTER As Long = &H40
Private Const WBF_BREAKLINE As Long = &H20 'AKA WBF_WORDBREAK
Private Const WBF_ISWHITE As Long = &H10 'AKA WBF_WORDWRAP

Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long


Private Sub RTB_Click()
Dim StPt As Long, LRet As Long
StPt = RTB.SelStart
LRet = SendMessageLong(RTB.hwnd, EM_FINDWORDBREAK, WB_CLASSIFY, StPt)
Label1.Caption = CStr(LRet)
End Sub

Explanation of the different values that show
in the label (which are a combination of the WBF
flags and the character classification):

"A delimiter is a character that marks the end of a word, such as a space.
In an edit control, word breaks occur only after delimiters.

Word break procedures for rich edit controls also group characters into
character classes, each identified by a value in the range 0x00 through
0x0F. Word breaks occur either after delimiters or between characters of
different classes. Thus, a word break procedure with different classes for
alphanumeric and punctuation characters would find two word breaks in the
string "WIN.COM"."

If you use the WB_ISDELIMITER flag with
EM_FINDWORDBREAK it returns True for a space
and False for everything else. But if you use
WB_CLASSIFY you can see that alphanumeric
characters return 0, while punctuation marks
return various values.

There's also EM_SETWORDBREAKPROC which allows
setting a callback function to take over word break
functionality. I've never tried it. The docs seem to
imply that your callback would only be called when a
line needs to be broken.



From: Kevin Provance on
I think I found the perfect solution to this, solving all our match case and
whole word problems. Thing is, it needs to be a RTB. Notepade doesn't
support whole word flags.

Want to change this to a RTB example?

--
Customer Hatred Knows No Bounds at MSFT
Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc

Bawwk! Paulie want a dingleball, bawwk!
"Karl E. Peterson" <karl(a)exmvps.org> wrote in message
news:i0gr46$7hk$1(a)news.eternal-september.org...
: Kevin Provance was thinking very hard :
: > "Leo" <ttdhead(a)gmail.com> wrote in message
: > news:i0gq49$u7o$1(a)news.eternal-september.org...
: >>
: >> I would have thaught INSTR would do the trick for finding and using a
: >> module level variable for keeping track of where to start searching
: >> from and maybe one for the search term too check if we it is a new
: >> term/string to search for.
: >
: > Many moons ago I rolled my own Find/Replace which is no longer used in
: > production, but as I never delete anything code wise, I would imagine
it's
: > still around someplace and would work great with this project.
: >
: > I guess maybe - considering Karl's events - I would pass the whole text
and
: > also pass back the position to highlight using the Find/Replace events.
: > Replace all I would handle all at once with Replace, allowing for case
: > sensitive searches and the like. I guess we would be grateful there
isn't
: > pattern matching included.
: >
: > There a bunch of different ways to go here. I have confidence Karl will
: > pick (or rather, write) the best. <g>
:
: It's the "Match whole words only" part where it really gets spooky. <g>
: I remember entering a contest Crescent Software held back in the 80s
: to see who could write the fastest Word Counter app with QuickBasic.
: OMG, the issues come at you fast and furious, and at some point you
: just have to close your eyes and *hope*. <g>
:
: Proposal: Go ahead with Instr, and when you find a match check the
: character before and after to see if it's alpha? Would that cover 99%
: of the cases? Of course, "back in the day", no one used those funky
: accented upper-ASCII things, either.
:
: And if you *really* wanted to write an all-purpose routine, you'd have
: to include full-on Unicode support, too, eh? I have no idea how to
: define a "whole word" in that realm.
:
: --
: .NET: It's About Trust!
: http://vfred.mvps.org
:
:

From: Leo on
It happens that Kevin Provance formulated :
> I think I found the perfect solution to this, solving all our match case and
> whole word problems. Thing is, it needs to be a RTB. Notepade doesn't
> support whole word flags.
>
> Want to change this to a RTB example?
>
> --
> Customer Hatred Knows No Bounds at MSFT
> Free usenet access at http://www.eternal-september.org
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>
> Bawwk! Paulie want a dingleball, bawwk!
> "Karl E. Peterson" <karl(a)exmvps.org> wrote in message
> news:i0gr46$7hk$1(a)news.eternal-september.org...
>> Kevin Provance was thinking very hard :
>>> "Leo" <ttdhead(a)gmail.com> wrote in message
>>> news:i0gq49$u7o$1(a)news.eternal-september.org...
>>>>
>>>> I would have thaught INSTR would do the trick for finding and using a
>>>> module level variable for keeping track of where to start searching
>>>> from and maybe one for the search term too check if we it is a new
>>>> term/string to search for.
>>>
>>> Many moons ago I rolled my own Find/Replace which is no longer used in
>>> production, but as I never delete anything code wise, I would imagine it's
>>> still around someplace and would work great with this project.
>>>
>>> I guess maybe - considering Karl's events - I would pass the whole text
>>> and also pass back the position to highlight using the Find/Replace events.
>>> Replace all I would handle all at once with Replace, allowing for case
>>> sensitive searches and the like. I guess we would be grateful there isn't
>>> pattern matching included.
>>>
>>> There a bunch of different ways to go here. I have confidence Karl will
>>> pick (or rather, write) the best. <g>
>>
>> It's the "Match whole words only" part where it really gets spooky. <g>
>> I remember entering a contest Crescent Software held back in the 80s
>> to see who could write the fastest Word Counter app with QuickBasic.
>> OMG, the issues come at you fast and furious, and at some point you
>> just have to close your eyes and *hope*. <g>
>>
>> Proposal: Go ahead with Instr, and when you find a match check the
>> character before and after to see if it's alpha? Would that cover 99%
>> of the cases? Of course, "back in the day", no one used those funky
>> accented upper-ASCII things, either.
>>
>> And if you *really* wanted to write an all-purpose routine, you'd have
>> to include full-on Unicode support, too, eh? I have no idea how to
>> define a "whole word" in that realm.
>>
>> --
>> .NET: It's About Trust!
>> http://vfred.mvps.org
>>
>>

I think it would be nice to still have it work with a textbox as thats
what my app currently uses, but I may convert it to a RTB if I can work
out issues.

--
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org