Page 1 of 1

Find script for a field search

Posted: Sun Aug 21, 2011 5:37 pm
by herbwords
Hi to all,

I've asked this question before and the scripts I've received have only been able to find once.

Does anyone have a button script to use on a field called "supplies" that will:

ask "Find What?"
find it
find it again when I press the Return key
and when it can't find it again by pressing the Return key Answer " it was not found"

Thanks,

Patrick

Re: Find script for a field search

Posted: Sun Aug 21, 2011 11:43 pm
by jmburnod
Hi Patrick,

Try this script

Code: Select all

local sString

on debSearch
   ask "Find What?"
   put it into sString
   returnkey
end debSearch

on returnkey
   find sString in fld "Supplies"
    select empty --prevent the return in field
    if  the foundChunk = empty then answer " it was not found"
    select empty --prevent the return in field
end returnkey
Best regards

Jean-Marc

Re: Find script for a field search

Posted: Mon Aug 22, 2011 4:27 am
by herbwords
Jean-Marc,

Thank you. Very nice script. It works very well but if I keep pressing return after the last find I press it again and nothing happens, then I press it again an it starts at the first find. What's happening on the the find after the last find when nothing appears. I would think when it finds the last occurrence it would either start again or say "it was not found"

Patrick

Re: Find script for a field search

Posted: Mon Aug 22, 2011 9:37 am
by jmburnod
Hi Patrick,
What's happening on the the find after the last find when nothing appears
The answer dialog "it was not found" don't appear ?

Best

Jean-Marc

Re: Find script for a field search

Posted: Mon Aug 22, 2011 2:36 pm
by herbwords
Hi Jean-Marc,

I was wanting it to search again every time I pressed the return key. I added 2 words and it seems to be just fine!
After - ask "Find What?" I put in "with sString"

on mouseUp
debSearch
end mouseUp

local sString

on debSearch
   ask "Find What?" with sString
   put it into sString
   returnkey
end debSearch

on returnkey
   find sString in fld "Supplies"
    select empty --prevent the return in field
    if  the foundChunk = empty then answer " it was not found"
    select empty --prevent the return in field
end returnkey

Thanks Again!