struggle to use lineoffset

Richard Gaskin ambassador at fourthworld.com
Sat Jan 4 15:00:00 EST 2003


DVGlasgow at aol.com wrote:

> I have a field which following an assessment contains 56 lines, each with 4
> chunks of data and a category identifier  (in word 5).  I want the user to
> click on a line and all (8) of the lines containing data associated from the
> same category to hilite. All 56 lines are unique, so i thought that having
> extracted the category from the selectedline it would be easy to use
> lineoffset to identify all the lines containing the category identifier.
>
> But the script below doesn't work.  In fact, it doesn't seem to do anything.
> Debugging doesn't shed any light on what is going on - at least to me.
> 
> on mouseup
> get  the selectedtext of me
> put char 1 to 3 of word 5 of it into tcat
> repeat for each line i in me
> if i contains tcat then select line (lineoffset (i,me)) of me
> end repeat
> end mouseup
> 
> The field is set up to allow multiple noncontiguous hilited lines.
> Suggestions anyone?

You can assemble the lines to be selected into a comma-delimited list and
set the hilitedlines property of the field to that string:

 on mouseup
   get  the hilitedtext of me -- note this change from selectedtext
   put char 1 to 3 of word 5 of it into tcat
   put empty into tLineItems
   put 0 into tCounter
   repeat for each line i in me
      add 1 to tCounter
      if i contains tcat then put tCounter into \
        item (the number of items of tLineItems+1) of tLineItems
   end repeat
   set the hilitedLines of me to tLineItems
 end mouseup


This is off the top of my head, so it may need tweaking, but in the method
principle should work.

-- 
 Richard Gaskin 
 Fourth World Media Corporation
 Developer of WebMerge 2.1: Publish any database on any site
 ___________________________________________________________
 Ambassador at FourthWorld.com       http://www.FourthWorld.com
 Tel: 323-225-3717                       AIM: FourthWorldInc




More information about the use-livecode mailing list