Sorting lines on colour (color for some)
Peter Haworth
pete at lcsql.com
Thu Sep 18 13:54:47 EDT 2014
I thought this would work:
sort lines of field X by the backgroundcolor of each
... but it doesn't. I'm guessing because the lines go into some sort of
internal variable to be sorted at which point they lose their
backgroundcolor property.
Here's a handler that does it, offered for improvement by others.
on mouseUp
local tRedLines,tYellowLines,tCounter
put zero into tCounter
repeat for each line rLine in field "Text"
add 1 to tCounter
if the backgroundcolor of line tCounter of field "Text" is 255,0,0
then
put rLine & return after tRedLines
else
put rLine & return after tYellowLines
end if
end repeat
put tRedLines & tYellowLines into field "Text"
set the backgroundcolor of line 1 to (the number of lines in tRedLines)
of field "Text" to "red"
set the backgroundcolor of line (the number of lines in tRedLines)+1 to
-1 of field "Text" to "yellow"
end mouseUp
Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
On Thu, Sep 18, 2014 at 9:46 AM, Francis Nugent Dixon <effendi at wanadoo.fr>
wrote:
> Hi from Beautiful Brittany (where, finally, it is raining),
>
> I have a list in a field, with backgroundcolor of some lines red, some
> yellow.
> Does anybody know how to sort the lines to separate out the two colours ?
>
> I can do it using a shuffle mechanism, but it’s not elegant enough (:>) !!
>
> The sort container command doesn’t give me the impression that this is a
> one-liner …….
>
> He who uses the least lines of code will gain my immediate admiration ……
>
> —Francis
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list