I recall seeing a very elegant “for” loop construct in C, that would increment or decrement the loop variable automatically based on whether the initial value was more or less than the end condition value.
In other words, something like this:
fadeUpDown(startVal, stopVal /*, stepSize */ ) {
// SOME CODE THAT SETS UP WHETHER TO INCREMENT OR DECREMENT
for (int i=startVal ; i != stopVal ; ### SOME TRICKY CODE ### ) {
// The actual looped code
}
}
Having searched quite a bit for this code again, I have had no success, so here I am, asking if someone could help me with this.
Edit: We’re all integers here.
Sanity check on StopVal being an integral increment / decrement of StepSize is outside the scope.
Actually, let’s just skip StepSize and make it 1, in fact.
naja, e.g. simple approach: