deleting lines from a list-field

Jim Lambert jiml at netrin.com
Tue Jun 24 12:50:12 EDT 2008


>>
>> Why not sort the hilitedLines first?
>
> Thanks Jan but, the line order has to
> remain as is, or else my users
> would get distracted/confused by
> the visual effect.

Nicolas,

Jan's handler doesn't sort the actual contents of your list, just a  
copy of the hilitedLines.
So, the list's line order and its display remain unaffected. The user  
will simply see their selected lines disappear, which is the desired  
behavior.

I remember being totally stumped in the early HyperCard days by the  
same problem - how to delete a container's lines in a repeat loop? It  
didn't seem possible, because as soon as you deleted a line the line  
numbers would change and you'd end up deleting lines you should have  
kept. I tried all sorts of complex gyrations, including actually  
inserting numbers before the lines! Then a kind soul, Steve Nelson I  
think, advised, "Just work backwards." So simple! It taught me a  
bigger lesson. Sometimes a solution appears when you just flip the  
problem upsidedown.

Jim Lambert

> ##
> put the hilitedLines of me into tHilitedLines
> sort items of tHilitedLines numeric descending
> repeat for each item tLineNumber in tHilitedLines
>  delete line tLineNumber of me
> end repeat
> ##
>




More information about the use-livecode mailing list