deleting lines from a list-field
Jan Schenkel
janschenkel at yahoo.com
Tue Jun 24 00:39:58 EDT 2008
--- Nicolas Cueto <niconiko at gmail.com> wrote:
> I'm hoping there's an elegant
> way of doing the following,
> cause my "solution" is pretty
> messy.
>
> I have a locked field set to
> list-behavior, multiline, and
> non-contiguous. Now, say
> that in that field there are
> 10 lines, of which the user
> has selected lines 1, 3-to-6
> and 8 for deletion.
>
> My first solution so far is to
> put a mouseDouble up
> handler in the field and then
> use the field's hilitedline
> property, something like this:
>
> on mouseDoubleUp
> put the hilitedline of me into tLinesToDelete
> repeat for each item tLineNr in tLinesToDelete
> delete line tLineNr of me
> end repeat
> end mouseDoubleUp
>
> But, of course, the problem with
> this is that after the first deletion
> the line numbers in hilitedLine
> no longer correspond to the
> actual line numbers in the field.
>
> Like I say, I've kludged up one
> possibile way of doing this, but
> there's got to be a better way,
> isn't there?
>
> Thanks.
>
> --
> Nicolas Cueto
>
Hi Nicolas,
Why not sort the hilitedLines first?
##
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
##
Hope this helped,
Jan Schenkel.
Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
More information about the use-livecode
mailing list