Re: Sorting lines on colour (color for some)

2014-09-20 Thread Francis Nugent Dixon
Hi from beautiful Brittany,

Jacqueline,

I was already in a repeat loop to colour lines which contained certain field 
names,
so I just tacked in the addition of the RGB, and then sorted the field.
Then I added a three line repeat loop to remove the RGB data, and got what I 
wanted.

So I found, for my case, a short way to solve my problem. Howver, I agree that 
sorting
data on any type of colour parameter is an interesting addition (LOW, LOW 
priority)
to livecode.

And I have more interesting code suggestions,  from you all, for the future.

Thanks again to all.

-Francis


___
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


Re: Sorting lines on colour (color for some)

2014-09-19 Thread Francis Nugent Dixon
Hi from Beautiful Brittany,

Thanks to all you guys (and Jacqueline) for the wealth of suggestions
to solve my little problem. That’s a lot of brain power out there.

I had thought of tacking the colour code onto each line, sorting by
the normal way, and then stripping off the code.

But I knew that someone out there would have a mind-blowing answer  !
I like the regex use.

Thanks again

-Francis
___
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


Re: Sorting lines on colour (color for some)

2014-09-19 Thread BNig
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


Re: Sorting lines on colour (color for some)

2014-09-19 Thread J. Landman Gay

On 9/18/2014, 4:46 PM, dunb...@aol.com wrote:

Anyway, the backColor does not sort either, using the same code.


Jacque, why doesn't the thing sort?



I think it's because when you sort lines, the engine pulls out only the 
actual text of the line for sorting. It isn't looking at the properties 
of the field at all. That's why using htmltext or styledText works, 
because those are just text.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.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


Re: Sorting lines on colour (color for some)

2014-09-19 Thread Peter Haworth
QCC Report# 13492 submitted as an enhancement.  I doubt it will get a very
high priority but thought it worth documenting.

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 Fri, Sep 19, 2014 at 12:22 PM, J. Landman Gay jac...@hyperactivesw.com
wrote:

 On 9/18/2014, 4:46 PM, dunb...@aol.com wrote:

 Anyway, the backColor does not sort either, using the same code.


 Jacque, why doesn't the thing sort?



 I think it's because when you sort lines, the engine pulls out only the
 actual text of the line for sorting. It isn't looking at the properties of
 the field at all. That's why using htmltext or styledText works, because
 those are just text.

 --
 Jacqueline Landman Gay | jac...@hyperactivesw.com
 HyperActive Software   | http://www.hyperactivesw.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

___
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


Re: Sorting lines on colour (color for some)

2014-09-19 Thread dunbarx
OK, I get that. But then how would a function, something you in particular are 
fond of, work?


sort lines of whatever by jacque(the value of youTellMe)


Craig



-Original Message-
From: J. Landman Gay jac...@hyperactivesw.com
To: How to use LiveCode use-livecode@lists.runrev.com
Sent: Fri, Sep 19, 2014 3:23 pm
Subject: Re: Sorting lines on colour (color for some)


On 9/18/2014, 4:46 PM, dunb...@aol.com wrote:
 Anyway, the backColor does not sort either, using the same code.


 Jacque, why doesn't the thing sort?


I think it's because when you sort lines, the engine pulls out only the 
actual text of the line for sorting. It isn't looking at the properties 
of the field at all. That's why using htmltext or styledText works, 
because those are just text.

-- 
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.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

 
___
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


Re: Sorting lines on colour (color for some)

2014-09-19 Thread J. Landman Gay

On 9/19/2014, 8:18 PM, dunb...@aol.com wrote:

OK, I get that. But then how would a function, something you in
particular are fond of, work?


In this case I wouldn't use any field access, it would be inefficient 
and slow for all but very short field contents. But if someone put a 
knife to my throat and said, write a function or else, then I'd do it 
the same way Bernd did, only instead of counting lines in the 
styledText, I'd count lines in the field. It requires the engine to 
access the field repeatedly for every line and makes me wince:


local sCounter = 0

on mouseUp -- about to mangle Bernd's handler now
   put 0 into sCounter
   sort lines of field fData numeric ascending by myColor(each)
end mouseUp

function myColor
   add 1 to sCounter
   put the backcolor of line sCounter of fld fData into tRGB -- ow, ow

   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

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.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


Sorting lines on colour (color for some)

2014-09-18 Thread Francis Nugent Dixon
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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sorting lines on colour (color for some)

2014-09-18 Thread Mark Schonewille

Hi Francis,

I haven't tried this but it might work.

put the htmlText of fld x into myHtml
put char 4 to -5 of myHtml into myHtml
set the itemDel to 
sort lines of myHtml by item 1 of each
set the htmlText of fld x to p  myHtml  /p

If this doesn't work, it might at least give a clue of how to handle 
this kind of problems.


--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Installer Maker for LiveCode:
http://qery.us/468

Buy my new book Programming LiveCode for the Real Beginner 
http://qery.us/3fi


LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 9/18/2014 18:46, Francis Nugent Dixon 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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sorting lines on colour (color for some)

2014-09-18 Thread dunbarx
Well, I win the fewest lines prize, but surely lose in the does it work? 
category.


Anyone know why this fails?



on mouseUp
   sort lines of fld 1 numeric by sum(the foregroundColor of each)
end mouseUp


Craig Newman



-Original Message-
From: Mark Schonewille m.schonewi...@economy-x-talk.com
To: How to use LiveCode use-livecode@lists.runrev.com
Sent: Thu, Sep 18, 2014 12:52 pm
Subject: Re: Sorting lines on colour (color for some)


Hi Francis,

I haven't tried this but it might work.

put the htmlText of fld x into myHtml
put char 4 to -5 of myHtml into myHtml
set the itemDel to 
sort lines of myHtml by item 1 of each
set the htmlText of fld x to p  myHtml  /p

If this doesn't work, it might at least give a clue of how to handle 
this kind of problems.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Installer Maker for LiveCode:
http://qery.us/468

Buy my new book Programming LiveCode for the Real Beginner 
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 9/18/2014 18:46, Francis Nugent Dixon 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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 
___
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

Re: Sorting lines on colour (color for some)

2014-09-18 Thread dunbarx
Should better have been (though still not working):



on mouseUp
  sort lines of fld 1 numeric by item 1 of the foregroundColor of each  
item 2 of the foregroundColor of each  item 3 of the foregroundColor of each
end mouseUp



-Original Message-
From: dunbarx dunb...@aol.com
To: use-livecode use-livecode@lists.runrev.com
Sent: Thu, Sep 18, 2014 1:24 pm
Subject: Re: Sorting lines on colour (color for some)


Well, I win the fewest lines prize, but surely lose in the does it work? 
category.


Anyone know why this fails?



on mouseUp
   sort lines of fld 1 numeric by sum(the foregroundColor of each)
end mouseUp


Craig Newman



-Original Message-
From: Mark Schonewille m.schonewi...@economy-x-talk.com
To: How to use LiveCode use-livecode@lists.runrev.com
Sent: Thu, Sep 18, 2014 12:52 pm
Subject: Re: Sorting lines on colour (color for some)


Hi Francis,

I haven't tried this but it might work.

put the htmlText of fld x into myHtml
put char 4 to -5 of myHtml into myHtml
set the itemDel to 
sort lines of myHtml by item 1 of each
set the htmlText of fld x to p  myHtml  /p

If this doesn't work, it might at least give a clue of how to handle 
this kind of problems.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Installer Maker for LiveCode:
http://qery.us/468

Buy my new book Programming LiveCode for the Real Beginner 
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 9/18/2014 18:46, Francis Nugent Dixon 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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 


___
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

Re: Sorting lines on colour (color for some)

2014-09-18 Thread Phil Davis

My guess:
Try using the effective foregroundColor of each - that will cover your 
bases when there is no assigned foregroundColor.


Phil Davis


On 9/18/14, 10:24 AM, dunb...@aol.com wrote:

Well, I win the fewest lines prize, but surely lose in the does it work? 
category.


Anyone know why this fails?



on mouseUp
sort lines of fld 1 numeric by sum(the foregroundColor of each)
end mouseUp


Craig Newman



-Original Message-
From: Mark Schonewille m.schonewi...@economy-x-talk.com
To: How to use LiveCode use-livecode@lists.runrev.com
Sent: Thu, Sep 18, 2014 12:52 pm
Subject: Re: Sorting lines on colour (color for some)


Hi Francis,

I haven't tried this but it might work.

put the htmlText of fld x into myHtml
put char 4 to -5 of myHtml into myHtml
set the itemDel to 
sort lines of myHtml by item 1 of each
set the htmlText of fld x to p  myHtml  /p

If this doesn't work, it might at least give a clue of how to handle
this kind of problems.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Installer Maker for LiveCode:
http://qery.us/468

Buy my new book Programming LiveCode for the Real Beginner
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 9/18/2014 18:46, Francis Nugent Dixon 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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

  
___

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


--
Phil Davis


___
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

Re: Sorting lines on colour (color for some)

2014-09-18 Thread Peter Haworth
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 effe...@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@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode

___
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

Re: Sorting lines on colour (color for some)

2014-09-18 Thread Thierry Douez
Another one with some regex flavor


on mouseUp
   local t
   put the htmltext of fld 1 into t
   sort lines of t  by getHtmlColors( each)
   set  the htmltext of fld 1 to t
end mouseUp

function getHtmlColors L
   if matchText( L, p bgcolor=.#([0-9A-F]{6})., v) then  return v
   return z
end getHtmlColors

Thierry


Thierry Douez - http://sunny-tdz.com
Maker of sunnYperl - sunnYmidi - sunnYmage


2014-09-18 18:46 GMT+02:00 Francis Nugent Dixon effe...@wanadoo.fr:
 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@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode

___
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

Re: Sorting lines on colour (color for some)

2014-09-18 Thread Peter Haworth
Like that better than mine - good use of htmltext and regex!

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 11:01 AM, Thierry Douez th.do...@gmail.com wrote:

 Another one with some regex flavor


 on mouseUp
local t
put the htmltext of fld 1 into t
sort lines of t  by getHtmlColors( each)
set  the htmltext of fld 1 to t
 end mouseUp

 function getHtmlColors L
if matchText( L, p bgcolor=.#([0-9A-F]{6})., v) then  return v
return z
 end getHtmlColors

 Thierry

 
 Thierry Douez - http://sunny-tdz.com
 Maker of sunnYperl - sunnYmidi - sunnYmage


 2014-09-18 18:46 GMT+02:00 Francis Nugent Dixon effe...@wanadoo.fr:
  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@lists.runrev.com
  Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
  http://lists.runrev.com/mailman/listinfo/use-livecode

 ___
 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

___
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

Re: Sorting lines on colour (color for some)

2014-09-18 Thread Thierry Douez
2014-09-18 20:26 GMT+02:00 Peter Haworth p...@lcsql.com:

 Like that better than mine - good use of htmltext and regex!

 Pete

Thanks Peter,

and for those having real headacke with regex, you can write
the function this way:

function getHtmlColors L
   if offset( p bgcolor=, L)  1 then return z
   return char 12 to 18 of L -- the 6 hexa chars
end getHtmlColors


But I personaly find it extremely ugly :)

Regards,

Thierry


 On Thu, Sep 18, 2014 at 11:01 AM,
Thierry Douez th.do...@gmail.com wrote:

 Another one with some regex flavor

 on mouseUp
local t
put the htmltext of fld 1 into t
sort lines of t  by getHtmlColors( each)
set  the htmltext of fld 1 to t
 end mouseUp

 function getHtmlColors L
if matchText( L, p bgcolor=.#([0-9A-F]{6})., v) then  return v
return z
 end getHtmlColors

 Thierry




Thierry Douez - http://sunny-tdz.com
Maker of sunnYperl - sunnYmidi - sunnYmage

___
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


Re: Sorting lines on colour (color for some)

2014-09-18 Thread dunbarx
I made this more robust, though no more effective:



on mouseUp
  sort lines of fld 1 numeric by item 1 of the effective foregroundColor of 
each  item 2 of the effective foregroundColor of each  item 3 of the 
effective foregroundColor of each
end mouseUp


This so 0,255,255 does not sort the same as 255,0,255. And I tried using 
effective, as per Phil and as shown, but still no.


Peter, you need foreground color, not backgroundColor.


So again, before I call Jacque, why does this not work? Maybe calling the 
sortKey as a function? That should not fix it, though it would look prettier.


Craig



-Original Message-
From: Thierry Douez th.do...@gmail.com
To: How to use LiveCode use-livecode@lists.runrev.com
Sent: Thu, Sep 18, 2014 3:56 pm
Subject: Re: Sorting lines on colour (color for some)


2014-09-18 20:26 GMT+02:00 Peter Haworth p...@lcsql.com:

 Like that better than mine - good use of htmltext and regex!

 Pete

Thanks Peter,

and for those having real headacke with regex, you can write
the function this way:

function getHtmlColors L
   if offset( p bgcolor=, L)  1 then return z
   return char 12 to 18 of L -- the 6 hexa chars
end getHtmlColors


But I personaly find it extremely ugly :)

Regards,

Thierry


 On Thu, Sep 18, 2014 at 11:01 AM,
Thierry Douez th.do...@gmail.com wrote:

 Another one with some regex flavor

 on mouseUp
local t
put the htmltext of fld 1 into t
sort lines of t  by getHtmlColors( each)
set  the htmltext of fld 1 to t
 end mouseUp

 function getHtmlColors L
if matchText( L, p bgcolor=.#([0-9A-F]{6})., v) then  return v
return z
 end getHtmlColors

 Thierry




Thierry Douez - http://sunny-tdz.com
Maker of sunnYperl - sunnYmidi - sunnYmage

___
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

 
___
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


Re: Sorting lines on colour (color for some)

2014-09-18 Thread J. Landman Gay

On 9/18/2014, 3:06 PM, dunb...@aol.com wrote:

Peter, you need foreground color, not backgroundColor.


So again, before I call Jacque, why does this not work?


I think backgroundColor really is what you want. Lines can have their 
own backcolor, forecolor is the color of the text.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.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


Re: Sorting lines on colour (color for some)

2014-09-18 Thread dunbarx

I thought the OP wanted colored text.  Anyway, the backColor does not sort 
either, using the same code.


Jacque, why doesn't the thing sort?


Craig



-Original Message-
From: J. Landman Gay jac...@hyperactivesw.com
To: How to use LiveCode use-livecode@lists.runrev.com
Sent: Thu, Sep 18, 2014 5:18 pm
Subject: Re: Sorting lines on colour (color for some)


On 9/18/2014, 3:06 PM, dunb...@aol.com wrote:
 Peter, you need foreground color, not backgroundColor.


 So again, before I call Jacque, why does this not work?

I think backgroundColor really is what you want. Lines can have their 
own backcolor, forecolor is the color of the text.

-- 
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.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

 

___
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


Re: Sorting lines on colour (color for some)

2014-09-18 Thread Peter Haworth
My script works with background color so I guess that must be the right
property.

It would be great if something like sort lines of field x by the
backgroundcolor of each just worked though.  Not just with backgroundcolor
but with any property of a line in a field.  Worth an enhancement request?

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 2:18 PM, J. Landman Gay jac...@hyperactivesw.com
wrote:

 On 9/18/2014, 3:06 PM, dunb...@aol.com wrote:

 Peter, you need foreground color, not backgroundColor.


 So again, before I call Jacque, why does this not work?


 I think backgroundColor really is what you want. Lines can have their
 own backcolor, forecolor is the color of the text.

 --
 Jacqueline Landman Gay | jac...@hyperactivesw.com
 HyperActive Software   | http://www.hyperactivesw.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

___
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


Re: Sorting lines on colour (color for some)

2014-09-18 Thread Mike Bonner
No time to test right now, but shouldn't it be possible to use the
styledtext array as part of the sort?  The data in the array is in the form
of..

myArray[tCounter][runs][1][style][textColor]

where tCounter is the line number (aka, paragraph number)

It can get complicated fast if lines have more than 1 run, but maybe
something in there could be useful.  Just thinking off the top of my head,
grab the array, flatten it and tack on the text for each line, do the sort
on the colors, (though if there is a line with no color set, the array
entry for that line will be empty, but the array key for the paragraph does
exist, not sure how to handle an unset textcolor key yet), rebuild the
array, renumbering by paragraph based on the new line positions, then pop
the text back into the field, and set the styledtext to the new array.

Could be a royal pain, but a pain that works is better than a simple that
doesn't.

On Thu, Sep 18, 2014 at 3:46 PM, dunb...@aol.com wrote:


 I thought the OP wanted colored text.  Anyway, the backColor does not sort
 either, using the same code.


 Jacque, why doesn't the thing sort?


 Craig



 -Original Message-
 From: J. Landman Gay jac...@hyperactivesw.com
 To: How to use LiveCode use-livecode@lists.runrev.com
 Sent: Thu, Sep 18, 2014 5:18 pm
 Subject: Re: Sorting lines on colour (color for some)


 On 9/18/2014, 3:06 PM, dunb...@aol.com wrote:
  Peter, you need foreground color, not backgroundColor.
 
 
  So again, before I call Jacque, why does this not work?

 I think backgroundColor really is what you want. Lines can have their
 own backcolor, forecolor is the color of the text.

 --
 Jacqueline Landman Gay | jac...@hyperactivesw.com
 HyperActive Software   | http://www.hyperactivesw.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



 ___
 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

___
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