 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Humphrey Guest
|
Posted: Sat Nov 29, 2003 10:47 pm Post subject: backwards text search |
|
|
can anyone help in a method for finding previous instances of a text
string (eg a word). We are using this code to find strings going
forward through a text file in a richedit box but how can you go
backwards?
Thanks for any suggestions.
procedure TfrmFind.ImageArrowRClick(Sender: TObject);
var
StartPosLI, ToEndLI,LineindexLI : Integer;
begin
frmLibrary.RichEdit.SetFocus;
with frmLibrary.RichEdit do
begin
if SelLength <> 0 then
StartPosLI := SelStart + SelLength
else
StartPosLI := 0;
ToEndLI := Length(Text) - StartPosLI;
FoundAtLI := FindText(edtFindText.Text, StartPosLI,
ToEndLI,[]);
if FoundAtLI <> -1 then
begin
SetFocus;
SelStart := FoundAtLI;
SelLength := Length(edtFindText.Text);
frmLibrary.RichEdit.Perform(EM_SCROLLCARET, 0, 0);
end;
end;
|
|
| Back to top |
|
 |
Maarten Wiltink Guest
|
Posted: Sat Nov 29, 2003 11:45 pm Post subject: Re: backwards text search |
|
|
"Humphrey" <j.humphrey (AT) xtra (DOT) co.nz> wrote
| Quote: | can anyone help in a method for finding previous instances of a text
string (eg a word). We are using this code to find strings going
forward through a text file in a richedit box but how can you go
backwards?
Thanks for any suggestions.
|
<snip code>
That code doesn't appear to find strings at all judging from what
my help file says about FindText. It may not be the same FindText,
though. My help file seems to list quite different parameters.
Apart from that, how hard have you *tried* to do this? Neither the
question itself nor the code fragment inspire much confidence in
that.
Groetjes,
Maarten Wiltink
|
|
| Back to top |
|
 |
Humphrey Guest
|
Posted: Sun Nov 30, 2003 7:42 am Post subject: Re: backwards text search |
|
|
"Maarten Wiltink" <maarten (AT) kittensandcats (DOT) net> wrote
| Quote: | "Humphrey" <j.humphrey (AT) xtra (DOT) co.nz> wrote in message
news:a1462659.0311291447.69a1a79b (AT) posting (DOT) google.com...
can anyone help in a method for finding previous instances of a text
string (eg a word). We are using this code to find strings going
forward through a text file in a richedit box but how can you go
backwards?
Thanks for any suggestions.
snip code
That code doesn't appear to find strings at all judging from what
my help file says about FindText. It may not be the same FindText,
though. My help file seems to list quite different parameters.
Apart from that, how hard have you *tried* to do this? Neither the
question itself nor the code fragment inspire much confidence in
that.
Groetjes,
Maarten Wiltink
|
Hi Maarten
the code works ok in a little E-book reader that I have designed for
my studies but our tutor commented that he felt the 'findtext' only
worked forward through a text, not backward. I am still learning the
art of Delphi and have tried to prove him wrong but no success so was
only looking for some suggestion on another avenue to take. Have you
any?
|
|
| Back to top |
|
 |
Maarten Wiltink Guest
|
Posted: Sun Nov 30, 2003 2:56 pm Post subject: Re: backwards text search |
|
|
"Humphrey" <j.humphrey (AT) xtra (DOT) co.nz> wrote
| Quote: | the code works ok in a little E-book reader that I have designed for
my studies but our tutor commented that he felt the 'findtext' only
worked forward through a text, not backward. I am still learning the
art of Delphi and have tried to prove him wrong but no success so was
only looking for some suggestion on another avenue to take. Have you
any?
|
Your FindText, which as I've commented appears to be a different one
from the one my help file explains, takes four parameters.
Investigate these parameters.
This tutor, exactly what is he tutoring you with? Developing said e-book
reader, by any chance? In cases of suspected homework, I get rather less
forthcoming with concrete advice.
Groetjes,
Maarten Wiltink
|
|
| Back to top |
|
 |
Nicolai Hansen Guest
|
Posted: Wed Dec 03, 2003 7:55 am Post subject: Re: backwards text search |
|
|
| Quote: | This tutor, exactly what is he tutoring you with? Developing said e-book
reader, by any chance? In cases of suspected homework, I get rather less
forthcoming with concrete advice.
Groetjes,
Maarten Wiltink
|
Hmm.. Maarten.. if you don't wanna do my homework, can I convince you
to do my job instead? :)
|
|
| Back to top |
|
 |
J French Guest
|
Posted: Wed Dec 03, 2003 10:45 am Post subject: Re: backwards text search |
|
|
On 29 Nov 2003 14:47:07 -0800, [email]j.humphrey (AT) xtra (DOT) co.nz[/email] (Humphrey) wrote:
| Quote: | can anyone help in a method for finding previous instances of a text
string (eg a word). We are using this code to find strings going
forward through a text file in a richedit box but how can you go
backwards?
Thanks for any suggestions.
|
You just decrement the StartPos in the FindText method
( and increment the length )
Personally I would develop a strategy of decrementing it in blocks and
repeatedly using RE.FindText .. until I found the last before the
real 'startpos'
Incidentally, that is probably what your tutor is trying to get you to
work out for yourself
- how to develop a 'search strategy'
|
|
| Back to top |
|
 |
Maarten Wiltink Guest
|
Posted: Wed Dec 03, 2003 2:21 pm Post subject: Re: backwards text search |
|
|
"Nicolai Hansen" <nic (AT) aub (DOT) dk> wrote
| Quote: | This tutor, exactly what is he tutoring you with? Developing said e-book
reader, by any chance? In cases of suspected homework, I get rather less
forthcoming with concrete advice.
Groetjes,
Maarten Wiltink
Hmm.. Maarten.. if you don't wanna do my homework, can I convince you
to do my job instead?
|
Yes. Always. Erm... Can I see your paycheck? Never mind, can I _have_
your paycheck?
Seriously, I don't mind helping people but I would like them to learn
the general case from it, not just the one trick. I'm just funny that
way. I know it's driving my dad batty; he's learned not to ask me some
things. I hate that, because I _want_ to help him, but I just can't
restrict myself to what he asks.
People tend to have the same job next month, but different classes.
This translates to quite different priorities. With the same job next
month, you want to not have the same problem next month. With different
classes, you know you're not going to have the same problem.
Groetjes,
Maarten Wiltink
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|