DADiSP Worksheet Functions > Function Categories > Colors > COLORSTR
Returns the color index corresponding to a color name.
COLORSTR("name")
"name" |
- |
A string, the name of the color. |
An integer, the color number.
colorstr("blue")
returns 1.
colorstr(strcolor(13))
returns 13, indicating COLORSTR and STRCOLOR are inverse functions.
Most pre-defined colors also have an associated macro to retrieve the color number. For example, the macro LRED is defined as 12, the color value for light red. The statement
colorstr("LRED")
also returns 12, so the statements
sercolor(lred) and sercolor(colorstr("lred"))
are equivalent. However, COLORSTR is useful if the color value does not have an associated name or if the color name includes spaces. For example:
defcolor("Sky Blue", 0.651, 0.793, 0.942)
sercolor(colorstr("Sky Blue"))
defines a new color named Sky Blue and sets the current series to that color.