The BitNumber attribute is not limited to the data type size of the data the Target points to. So you will have to calculate bit numbers across word boundaries. For example, if you want to overlay Code[1].0, the Target attribute would be Code and the BitNumber attribute would be 16.
Code[2].0 would be Target=Code, BitNumber=32
Code[3].0 would be Target=Code, BitNumber=48
As far as I can find you can only overlay on the bit level. You can't overlay an integer over a specific integer array index, for example.
Originally posted by drbitboy:
Is this the same as an EQUIVALENCE statement in Fortran?
Kind of...ish? I'm not a Fortran guy so I'm not familiar with the in's and out's of EQUIVALANCE. I would think that is similar to a union in C. Bit overlays are way more restrictive than that. I think they were really developed for the specific case where bit-packed words are used to transfer conditions. Bit overlays provide a way to develop a UDT that breaks the bits apart into meaningful items in a UDT without any data management. It is all under the hood, so to speak.
Bit overlays have their baggage. They can only be used as part of a UDT definition. And, as has already been stated, once you apply bit overlays the UDT cannot be edited in the Logix environment anymore. Bit overlays are defined in an L5X file external to the Logix environment and then imported. But for something you KNOW is not going to change, they do work.
Keith