I'm trying to do something to this affect:
const string first_color = strip.Color(0, 60, 0, 0);
With the intended outcome being that I could use first_color
wherever I'd have used strip.Color(0, 60, 0, 0)
before.
You pretty much need a helper function to do that; a small local function that calls strip.Color()
with the intended arguments and returns strip.Color()
's return value if there is any.
int first_color(void)
{
return(strip.Color(0, 60, 0, 0));
}
(assuming strip.Color()
returns an int
) which you would call with:
value = first_color();
If strip.Color()
is a void
function, then delete the 'return(' and one ')', fix the definition of first color to be void
instead of int
, and of course, don't try to use any return value from first_color()
.
It sounds like you might want a preprocessor macro:
#define FIRST_COLOR strip.Color(0, 60, 0, 0)
And then later
FIRST_COLOR;
This is basically just text substitution at the initial stage of the compilation process. It is somewhat conventional to make macros all caps, but not required. You can also define function-like macros which take arguments.
first_color
? There doesn't seem to be much point to calling it repeatedly with the same parameters, unless it has some side-effects that you're interested in.