Use of "flags" in programming - am I wrong?

I taught my kids how to switch driver modes on their robot. (They push two buttons at the same time and what was once the front of their robot becomes the back, and vice versa, so it’s easier for them to work with their particular design.) So they have a variable called DriverMode, which equals 1 or 0, which informs their program on which way is the front. I told them such a variable is called a “flag variable” but they reported back to me that the judges apparently didn’t like that term, and my kids said the judges had no idea what they were talking about. :frowning:

I’m not a software kinda person, and I’ve poked around trying to find out what such a variable should be called if not a “flag”, and I’m getting mixed results. Anybody have any suggestions? :confused:

Yes, it’s very common to call a variable that can be either true or false a flag.

“A flag is a variable (usually boolean, ie having only two values like true/false, off/on, yes/no, etc) that indicates some program state.” (programmingforums.org)

So yes, I believe that using the term “flag” is appropriate. I don’t understand why the judges thought that was the wrong term. They may have misunderstood them.

Okay, thanks, guys. I don’t feel so bad now. I don’t hover over my kids when the judges are around, so I sometimes get some strange feedback. Also, I know judges sometimes come from a wide variety of backgrounds, so it’s always possible in their particular field a “flag variable” means something else. All it takes is one hyper-expert who’s been released from his silo on a Saturday to nitpick my kids and thereby cause them to lose faith in my infallibility. :slight_smile:

Interestingly way back (James will know this one) in K&R C times there was no boolean type and flags were always an int variable where 0 equated to false and non-zero was true. Depending on the [modern] complier a boolean data type may still use more than 1 bit for storage.

int aFlag = 0;

aFlag = 1;
if(aFlag) … //evaluates true

aFlag = 0;
if(!aFlag) … //evaluates true

aFlag = -99;
if(aFlag) … //evaluates true

Most of what I use these day still has no built in boolean type, I never rely on it being available and define it as necessary.