Probably a silly question about 'find'

Devin Asay devin_asay at byu.edu
Thu Jan 18 12:03:48 EST 2007


On Jan 18, 2007, at 9:25 AM, Ken Ray wrote:

>
> On Jan 18, 2007, at 9:48 AM, Devin Asay wrote:

<snip>

>>
>> Find is probably not the best choice in this case. I would use the  
>> lineOffset function and look for 4 & tab, like this:
>>
>> put lineOffset(4 & tab,fld "thevalues") into tLineFound
>
> And I would add to that to precede the number to search for with a  
> CR just to be on the safe side:
>
>   put lineOffset(CR & 4 & tab,CR & fld "thevalues") into tLineFound
>
> This way, suppose you had a series of values where some lines may  
> be skipped and you want to know if a line *was* skipped; something  
> like:
>
> 1	1234
> 2	2.56
> 3	4.1
> 9	8.35
> 14	9.274
> 18	20.121
>
> WIthout the "CR" in there, you would match the line starting with  
> 14 if you just looked for ("4" & tab), but you wouldn't match it if  
> you look for (CR & "4" & tab). Note that it is very important that  
> you include the preceding CR with the list to find as well,  
> otherwise your lineoffset will be off. So it can't be:
>
>   lineOffset(CR & 4 & tab,fld "thevalues")
>
> but must be
>
>   lineOffset(CR & 4 & tab,CR & fld "thevalues")

Including the CR in the second argument also ensures that an entry on  
the first line of the field will not be overlooked in the search.

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list