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
Search in more than text field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Search in more than text field
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
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
Re: Search in more than text field
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?
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?
Re: Search in more than text field
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
If you need more felxability, you should not use FIND but rather a form of OFFSET!
Best
Klaus
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

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
...
Best
Klaus
Re: Search in more than text field
Thanks Klaus
Thanks all
It is working.
Thanks all
It is working.