Re: Using Boolean Attribute in IF statements? llandale - Tue Feb 01 09:07:52 EST 2011
Yes, 'if (obj.MyBool "" == "True")' works. That's because a boolean attribute is just an enumerated attribute with two values, "True" and "False" (capital letters). However, there are some DXL perms that know that an attr ref is a boolean and translates it for you. Also, this works: "bool b = obj.MyBoolAttr" works but that has to do with the enumerations related number, turns false if its zero returns true otherwise.
Wrote this function and use it some, but I guess mostly because I have ADHD:
//************* bool fBoolOf(string Value)
{
// Turn the string Value into a Boolean.
// Specifically if (ignoring case) its exactly "True" (any case) return(true),
// otherwise return(false).
// Note: The length check prevents massive memory leak in case this function
// is called with a huge string Value.
if (length(Value) != 4)
return(
false)
return(lower(Value) ==
"true")
}
// end fBoolOf()
|