Hi Mike, I like your idea to use styledText very much. It turns out that for the backgroundColor of a line it is not too bad to handle.
------------------------------------------- local sCounter = 0 local sStyles = "" on mouseUp put 0 into sCounter put the styledText of field "fData" into sStyles sort lines of field "fData" numeric ascending by myColor(each) end mouseUp function myColor add 1 to sCounter put sStyles[sCounter]["style"]["backgroundColor"] into tRGB if tRGB = "" then -- no backgroundColor return 0 end if return item 1 of tRGB -- test for redness -- or do anything you want with R,G,B end myColor ------------------------------------------------ the real problem starts when you have the RGB value. What do you want to sort if it is a generic handler for all sorts of colors (e.g. any line of the colorNames) I made a version where I use Raney's conversion from RGB to HSV, then you can sort by Color (H=Hue), Saturation(S) and "Blackness" (V=Value). But still it is not what one expects. It sorts alright but it all depends on how you want your colors sorted. That makes a sort by backgroundColor (RGB value) less useful. Kind regards Bernd Scott Raney's RGB to HSV is in stack revColorChooser which on my Mac is in Livecode bundle Contents->Tools->Toolset-> revcolorchooser.rev in the script of group "HSV", there is also the other way around HSV to RGB. here is RGB to HSV ------------------------------------------- function RGBtoHSV r, g, b local maxv, minv, diff, s, rc, gc, bc, h set the numberFormat to "0.###############" put r / 255 into r put g / 255 into g put b / 255 into b put max(r,g,b) into maxv put min(r,g,b) into minv put maxv - minv into diff if maxv <> 0 and diff <> 0 then put diff / maxv into s put (maxv - r) / diff into rc put (maxv - g) / diff into gc put (maxv - b) / diff into bc if r = maxv then put bc - gc into h else if g = maxv then put 2 + rc - bc into h else if b = maxv then put 4 + gc - rc into h multiply h by 60 if h < 0 then add 360 to h end if else put 0 into s put 0 into h end if return round(h),round(s * 100),round(maxv * 100) end RGBtoHSV -------------------------------------- -- View this message in context: http://runtime-revolution.278305.n4.nabble.com/Sorting-lines-on-colour-color-for-some-tp4683418p4683474.html Sent from the Revolution - User mailing list archive at Nabble.com. _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode