I have a variable, timePtr, that holds a location in the EEPROM as I step through it for sprinkler timing programs. I have also read runTimesThisProgram from the EEPROM.
I wish to loop starting at the current value, making exactly runTimesThisProgram passes.
I started with
for (timePtr; timePtr < timePtr + runtimesThisProgram; ) {
In hindsight ( :o ), this never completes, as I observed running the loop. (I had the notion that the rhs of the termination condition would execute once.
I was surprised to find that
for (timePtr; timePtr < (unsigned int lastPass = (timePtr + runtimesThisProgram)); ) {
doesn't allow the creation of lastPass.
So I currently have
for (byte pass =0; pass<runtimesThisProgram; pass++ ) {
...
byte timeNxt = EEPROM.read(timePtr++); //the runtime or first byte
...
}
This seems "clunky", and that it would be more readable if the initial line had all the information.
What is the "best" way to handle this kind of situation?