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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: search

Post by jacque » Mon Aug 25, 2014 6:47 pm

Code: Select all

put the short name of this cd  into tRef
This line will cause a failure if any comment field has more than one instance of the search term in it. The second match will cause the handler to think it is done searching and it will exit prematurely. The foundchunk must be recoreded in the list, the way the original did, do ensure each line is unique.

Any change you make to the text of the field will be permanent, whether it is the color (my example) or the text style, or anything else. To get rid of the temporary styling, you can write a preOpenCard handler that removes it:

Code: Select all

on preOpenCard
  put the text of fld "comment" into fld "comment"
end preOpenCard
That is a quick way to remove all styling. Another way to do the same thing is:

Code: Select all

set the textstyle of char 1 to -1 of fld "comment" to "plain"
Neither method will work if the field has other text styling already, because it will remove styles from all the text, not just the text that was found. If you need to remove the styling from only the found text, then you will need to save the list the handler created (in a global variable, a custom property, or a script local) and loop through it, resetting the style of the characters it recorded in the foundchunk. (Which is another reason to preserve the foundchunk in the list.)

If you don't want yellow text, you can set the box yourself by using the textstyle "box".

As you noticed, LiveCode's automatic boxed text only displays for a single found chunk at a time. If you want them all displayed simultaneously, you have to set textstyles the way we're doing it here.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: search

Post by robm80 » Tue Aug 26, 2014 6:44 am

I shortened the findscript, the script finds the cards, but draws a box around the found word on the first card only.
Is there a way to mark the words on each card ?

Code: Select all

on mouseUp
   put empty into tZoekstring
   put empty into btn "foundbox" --a combobox
  
   ask "What word"
   put it into tZoekstring
   put number of cards into tNum
   
   if tZoekstring is empty then
      break
   end if
    
   lock screen
   repeat with i=5 to tNum
      find tZoekstring in fld "comment"
      put the short name of this card into tSn
      if tSn is not in btn "foundbox" then
      put tSn & cr after btn "foundbox"
      end if
   end repeat
   unlock screen
end mouseUp
If I remove "with=5 to tNum", the script runs in a loop (I think); it never comes to an end :!:

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: search

Post by robm80 » Tue Aug 26, 2014 7:02 am

I think I know why:
All cards must have the box drawn. The short names of those cards are in the comobox.
The combobox goes to the card clicked and that must be the moment that card looses its drawn box.
How to prevent that?
Rob

Post Reply