Find script for a field search

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
herbwords
Posts: 70
Joined: Sat Dec 01, 2007 2:59 am

Find script for a field search

Post by herbwords » Sun Aug 21, 2011 5:37 pm

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Find script for a field search

Post by jmburnod » Sun Aug 21, 2011 11:43 pm

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
https://alternatic.ch

herbwords
Posts: 70
Joined: Sat Dec 01, 2007 2:59 am

Re: Find script for a field search

Post by herbwords » Mon Aug 22, 2011 4:27 am

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Find script for a field search

Post by jmburnod » Mon Aug 22, 2011 9:37 am

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
https://alternatic.ch

herbwords
Posts: 70
Joined: Sat Dec 01, 2007 2:59 am

Re: Find script for a field search

Post by herbwords » Mon Aug 22, 2011 2:36 pm

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!

Post Reply