Hi,
my understanding was that a new loop is a new lop regardles of what happened in previous loop, but looks like that is not the case.
The PICaxe system resets all (normal) variables to zero
BEFORE the program starts to run. But if this is an important part of how the program is required to work, then it's much better practice to actually specify the Var = 0 (or whatever). Maybe sometime later, the program might be converted to a different computer language or the Variable obtained from a different source (e.g. Reading from EPROM) where the value might not start at zero.
Also, the program "Loop"s (actually there are two) are something that
YOU (the Programmer) have created, the individual instructions cannot "know" that they are part of a loop. But even if the "Start" module did "know" that it was part of a loop, how could it know that it should behave differently (i.e. Reset the Var.) if the previous instruction was in the "Yes" path but not in the "No" path ?
There are "formal" Loop instructions (e.g. DO .. : LOOP UNTIL var =2) but they still can't "guess" that a particular (or any) Variable needs to be Reset before (or after) they execute. The only command (that I can think of) which specifically does initialise the Loop is the FOR variable = .. TO .. : NEXT structure, but this will still only reset/load the
named variable, any others will be unchanged (or manipulated by the enclosed instructions as required).
Cheers, Alan.