Search Scrolling Field

J. Landman Gay jacque at
Thu Dec 29 22:59:27 EST 2005

Jeff Honken wrote:
> 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.

If the data will have only a single matching line, then:

   put me into N
   put fld "ProcListField" into tData
   set wholematches to true
   put line lineoffset(N,tData) of tData & cr after fld "summary"

If I understand what you want to do, this should accomplish the same 
thing without using a repeat loop.

If the goal is not necessarily to put data in the summary field, but 
rather just to hilite a line in the ProcListField field, then replace 
the last line above with:

   select line lineoffset(N,tData) of fld "procListField"

If the lineoffset is 0, then no lines will hilite, which is usually the 
correct behavior.

If your data may have more than one line that will match and you want to 
find them all, then you do need a repeat loop. You can repeat the 
lineoffset search and add a "skip" parameter -- see the docs for examples.

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

More information about the Use-livecode mailing list