Helpful tip: multiple kFlags must be "ORd" not "ANDd"

I want to share a tip that I stumbled over due to what seems like backwards logic. When using multiple kFlags for setting parameter properties like “Cannot Automate”, “Is Meta”, etc., those flags need to be “OR’d” together not “AND’d” together.

At first “AND” seemed logical since I wanted flagX and flagY but these values are bits in an overall flag binary. So to get both flags implemented we need to OR the flags like this:

IParam::kFlagMeta | IParam::kFlagCannotAutomate

I originally mistakenly AND’d the flags which caused neither to work (0 AND’d with 1 is 0). So, do not do this:

IParam::kFlagMeta & IParam::kFlagCannotAutomate

as it does not apply either flag!

Just one of those “Oh wait!” lessons learned that I thought I’d post that might help others.

1 Like

Flags are nothing more than ints with a value of 2^x, with x representing the according binary digit.
So if you want to combine them you have to add them which is the | operator on the binary level.

Yes - which defies common sense to AND (&) them, i.e., this flag and this other flag.

Stupid me for thinking logically vs “logic-ly”! As you said, “OR” (|) is the correct operator here.