Expression with getBit() on UDT Custom Property

Using the getBit() function on a member of a UDT custom property throws errors in the Designer for: “Cannot call getBit() with a null value.” This happens on both windows and templates, and they pop up every time anything is done to the window or template.

In my case, I need to display a number of bit states out of some VFD Control and Status words, so a stack of error boxes appear frequently. At run-time, this appears to resolve, but not without numerous errors in the Java Console.



Since the template is tied to a UDT the values may be NULL initially. So just modify your expression to failover to a different value if NULL:try(getBit({Template.UDT::IntegerValue}, 0), 0)The try function will return 0 if the value is NULL or something is wrong.

Thanks, Travis.

While this works much better, it does seem that, longer-term, the UDT’s and Templates beg to deal more gracefully with the null value issues they present during both design time and start-up (for both expressions and scripting).

Don’t get me wrong, however, the UDT’s and Templates have been a godsend on the project I’m working on.

Thanks for your help.

OK, just learned something that I probably should have figured out before, but the major part of this problem was caused by not having a tag binding to the UDT custom property at design time. Even if a different UDT custom property binding is passed via a parameter upon opening, the window opens better (no errors in the Java Console) if it the window is saved with an initial UDT binding.