Search Scrolling Field

Klaus Major klaus at major-k.de
Thu Dec 29 17:06:28 EST 2005


Hi Jeff,

> I'm trying to write a script that will allow me to search a Scrolling
> field from a user inputed field.
>
> Here's what I have:
>
> 1.  The Scrolling field is populated by a database. It's name is
> ProcListField
>
> 2.  I have a field that I am putting in a value.
>
> 3.  I want to search the ProcListField and highlight the "line" that
> contains the word I'm searching with.
>
> I've been trying the below script but it doesn't seem to find anything
> in my ProcListField.  I think what it's doing is looking for me to  
> match
> the whole line and not an individual word within the line.  Does  
> anyone
> have any ideas on how I can accomplish this search?
>
> put me into N
>   put fld ProcListField into tData
>   put empty into tSummary
>   repeat with x = 1 to the number of lines of tData
>     if line x of tData = N then put x & "," after tSummary
>   end repeat
>   delete last char of tSummary
>
> My end plans were to take tSummary and grab the row ID from it and
> hilite the row within ProcListField.  I may be going about this
> completely wrong so any input would be helpful.

You can make this script a lot faster by using "repeat for each..."

Try this:
...
   put me into N
   put fld ProcListField into tData
   put empty into tSummary
   put 1 into tCounter
   ## see below...
   repeat for each line L in tData
     if L contains N then
         ## string N has been "found" in string L :-)
         put tCounter & "," after tSummary
     end if
     add 1 to tCounter
     ## ***
   end repeat
   delete last char of tSummary
...

*** since "repeat for each..." is "read only" we have to count up  
manually!


Regards

Klaus Major
klaus at major-k.de
http://www.major-k.de




More information about the use-livecode mailing list