int varA =0; int varB =0; int varC =0; int varD =0; int varE =0; int varF =0; int varG =0;
some one of them will be set =1 under certain conditions.
and used as:
if( varA == 1 ) {....}
or
if( varB == 1 ) {....}
........
What I am looking for is how to automatically reset all of them =0 except the one on using.
for example: if (varE ==1) {....} right here I need to reset all others =0, how to do please?
maybe some organizations have a style that requires a comment to explain the the for loop variable. my organization didn't (and i see no need for one)
but my organizations style did require the return type and arguments on separate lines, even when a comment was not provided (often obvious) and i find it easier to read the code with each on a separate line
What do you mean? Automatically? You mean when something else happens? You have to set them to 0. it doesn't matter how you organize them, array or not, the only way to set them to zero is to set them to zero.
If you have an array called Array and you want to change the third value just use
Array[3]=0
Also, instead of using 10 different boolean variables, why not just use one variable and set it to 1-10? If you always want to reset the others so only 1 is ever true, just use an int variable and set it to one value. No need to reset. And checking which is true is SOOO much easier.
If the values will only ever be 0 or 1, then consider using a single unsigned byte to hold all of them. Use bit manipulation to set/clear the bit(s) you want.
Well, since there are 10 boolean items to track, I suspect he'd have to used a 16 bit entity, either int or unsigned int.
For most people, bit manipulation falls into the category of 'advanced voodoo magic', so I'm afraid that unless the OP is intrigued by puzzles, or extremely pushed for memory in his Arduino, he'd be better off keeping these as boolean variables, whether numerically ordered, or in an array. Unless, of course, he's into learning, in which case, 'have at it'!