View Full Version : How to do a rapid search in large fields?


Steffen Bendix
10-20-2005, 10:04 AM
Hello,

in SuperCard 4.1.2 I need to rapidly search a field containing more than
16,000 words. It doesn't matter _what_ is to be found. It is only
important wheather a word is contained in this field. A "repeat" handler
is much too slow. The "find" command works not fast enough (up to seven
seconds on my 1,33 GHz iBook) except a word is _not_ found. How can I
accelerate the search routine?

In addition, I hid the field but every found text makes the field
visible again until a new search is started. I placed an object above
the hidden field but it "shines through" after a successful search. How
can I prevent this behavior?

Steffen

PS. I cannot afford the new SuperCard version by the way. So how can I
solve the problem with my version?

--
Die Newton-Seite:
http://home.arcor.de/steffen.bendix/Newton

Arthur Evans Jr
10-20-2005, 02:49 PM
In article <1h4q8tx.msmfib10evd4mN%steffen.news1[at]arcor.de>,
steffen.news1[at]arcor.de (Steffen Bendix) wrote:

> in SuperCard 4.1.2

I don't use SuperCard but perhaps my HC experience might help.

> I need to rapidly search a field containing more than
> 16,000 words.

Try using the offset function
if offset(sought_word, field "Foo") > 0 then

> In addition, I hid the field but every found text makes the field
> visible again until a new search is started.

Try
lock screen

Good luck!

Art Evans

Steffen Bendix
10-24-2005, 07:27 AM
Arthur Evans Jr <nospam[at]someISP.net> wrote:

> Try using the offset function
> if offset(sought_word, field "Foo") > 0 then

Thank you very much. That is the function that does the job. But
unfortunately it finds also words which contain parts of other words.
For instance: The word "chair" is searched but the offset function also
finds the word "chairs". How can I limit the function to find only the
needed words?

Steffen

--
Die Newton-Seite:
http://home.arcor.de/steffen.bendix/Newton

Mark Schonewille
10-24-2005, 02:16 PM
Steffen,

This might work for you

on mouseUp
put cd field "Test Field" into myVar
put xfindWord(myVar,"text")
end mouseUp

function xfindWord theText,theStr
if theStr is in theText then
if word 1 of theText is theStr then
return 1
else if last word of theText is theStr then
return (number of words of theText)
else
put offset(space & theStr & space,theText) into myPosition
put (number of words of char 1 to myPosition ¬
of theText) + 1 into myNr
return myNr
end if
end if
end xfindWord

Make a stack with a field "Test Field" and a button with this
script to test it.

Best,

Mark


Steffen Bendix wrote:
> Arthur Evans Jr <nospam[at]someISP.net> wrote:
>
>
>>Try using the offset function
>> if offset(sought_word, field "Foo") > 0 then
>
>
> Thank you very much. That is the function that does the job. But
> unfortunately it finds also words which contain parts of other words.
> For instance: The word "chair" is searched but the offset function also
> finds the word "chairs". How can I limit the function to find only the
> needed words?
>
> Steffen
>

--

eHUG coordinator
http://www.ehug.info
http://home.wanadoo.nl/mark.sch
http://www.economy-x-talk.com

Arthur Evans Jr
10-24-2005, 04:32 PM
In article <1h4s167.gnhu3943bgbmN%steffen.news1[at]arcor.de>,
steffen.news1[at]arcor.de (Steffen Bendix) wrote:

I said
> Try using the offset function
> if offset(sought_word, field "Foo") > 0 then
and steffen.news1[at]arcor.de (Steffen Bendix) replied
> Thank you very much. That is the function that does the job. But
> unfortunately it finds also words which contain parts of other words.
> For instance: The word "chair" is searched but the offset function also
> finds the word "chairs". How can I limit the function to find only the
> needed words?

You could use
if offset(sought_word & space, field "Foo") > 0 then
but that wouldn't find the word if it ended a sentence, or was followed
by comma, or ended a line, or other problems. You could test
individually for al of those that are possible in your database.

Or, try something like this:
put offset(sought_word, field "Foo") > 0 into X
if X > 0 then
put char X to (number of chars of field "Foo") of field "FOO" into Y
if word 1 of Y = sought_word then ...

Good luck!

Art Evans