Search in more than text field

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ali yehia
Posts: 16
Joined: Tue Aug 04, 2015 9:43 am

Search in more than text field

Post by ali yehia » Tue Aug 04, 2015 9:54 am

Hi all

I have more than text field. I need enable user put word and search on text fields to find it. How can I do it? How can I catch the result of find (true/false)?

Thanks

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Search in more than text field

Post by dunbarx » Tue Aug 04, 2015 8:22 pm

Hi.

The "find" command will search the entire stack if you tell it to. It can certainly search more than one field on one card. You should read about this command, including all its variations, in the dictionary.

Then make a test stack with several fields on several cards. Place some text in each field, and make sure you repeat that text here and there among those fields and among those cards.

Now experiment with the "find" command, as well as such functions as the "foundField", the "foundLine", etc. Write back with your progress.

Craig Newman

ali yehia
Posts: 16
Joined: Tue Aug 04, 2015 9:43 am

Re: Search in more than text field

Post by ali yehia » Sat Aug 08, 2015 12:31 pm

Thanks for your reply.

I use find function.

put the field "stext" into ttsearch
find ttsearch in the field "t98"

When find get the word, I show box around the word.
When find does not get the word, nothing.

How can I get the result of find in variable? or at least true/false?

Klaus
Posts: 14190
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Search in more than text field

Post by Klaus » Sat Aug 08, 2015 12:46 pm

Hi ali,

Hint:
Do not use the keyword THE when addressing objects in Livecode!
THE is for addressing custom properties or functions!

Bad:
## put the field "stext" into ttsearch
## find ttsearch in the field "t98"
Good:
put field "stext" into ttsearch
find ttsearch in field "t98"

To your question, as the docs state, check THE RESULT right after FIND,
it will be EMPTY on success and "Not found" well, you guess :D

Code: Select all

...
put field "stext" into ttsearch 
find ttsearch in field "t98" 
if the result <> empty then
   answer the result
  ## -> Not found"
end if
...
If you need more felxability, you should not use FIND but rather a form of OFFSET!


Best

Klaus

ali yehia
Posts: 16
Joined: Tue Aug 04, 2015 9:43 am

Re: Search in more than text field

Post by ali yehia » Mon Aug 10, 2015 4:42 pm

Thanks Klaus
Thanks all
It is working.

Post Reply