Author Topic: Translate CECOLOR from RGB string to OLE color  (Read 1237 times)

0 Members and 1 Guest are viewing this topic.

Pepe

  • Newt
  • Posts: 87
Translate CECOLOR from RGB string to OLE color
« on: August 20, 2020, 07:52:17 AM »
A simple question:

My current editor color is set as a 'true color' (CECOLOR variable value is a string) and I need to translate it into an OLE color number.

Is there any easier way to get it rather than dealing with the string?

hmspe

  • Bull Frog
  • Posts: 362
Re: Translate CECOLOR from RGB string to OLE color
« Reply #1 on: August 20, 2020, 08:45:42 AM »
No direct conversion that I know of, but Lee Mac's LM:parsenumbers function makes handling the string easy.
"Science is the belief in the ignorance of experts." - Richard Feynman

RGUS

  • Newt
  • Posts: 106
Re: Translate CECOLOR from RGB string to OLE color
« Reply #2 on: August 20, 2020, 10:13:39 AM »
Lee Mac has the answer. I hope I can post this link Lee.
http://www.lee-mac.com/colourconversion.html

Pepe

  • Newt
  • Posts: 87
Re: Translate CECOLOR from RGB string to OLE color
« Reply #3 on: August 20, 2020, 10:50:58 AM »
Thank you both!

I know those useful Lee-Mac's works.

This is the way I get it dealing with the string and using Lee-Mac's stuff:

Code - Auto/Visual Lisp: [Select]
  1. (eval (read (strcat "(LM:RGB->OLE " (vl-string-translate "," " " (vl-string-left-trim "RGB:" (getvar "CECOLOR"))) ")")))
  2. ;;other way
  3. (apply 'LM:RGB->OLE (read (strcat "(" (vl-string-translate "," " " (vl-string-left-trim "RGB:" (getvar "CECOLOR"))) ")")))

So, i was trying to find a shortcut... :whistling: