OK I will try to answer all the questions in one hit.
The platform is RSlogix 5000 V28 using an L73 CPU.
I want a universal solution for unknown UDT size.
Thinking about it, the reason I want to do this is maybe moot.
I am passing in an array of a specific UDT. I wanted to get the code in the add-on instruction to check that the parameter being passed in is of the expected type.
The way I was going to do this was to divide the array definition size in bytes by the UDT size in bytes and I would expect to get a whole number if the parameter being passed in was of the correct type (UDT). I.e. it would be whole number of UDT's in size.
The reason for doing it this was that it was a port of some software from the S7 world whereby the passed in parameter was an ANY pointer that pointed to the array of UDT's.
Now as the ANY pointer can point to data of any type, it needed some form of check to validate that the correct data type was being pointed at. I realise that the check is not foolproof, but it is better than nothing.
So it was my intention of trying a similar thing on the ported code in the bradley.
So parameter passed in is UDT[n] where n is unknown.
The AOI has the input type of UDT[1].
The AOI then goes round a loop of n copying each array element to a local tag of type UDT. Now this I have already tested. I can get n using the SIZE operator and the COP operator can access all the array parameters (even though the input is defined as [1]).
However I want to prevent someone calling the AOI with a tag that is not an array of UDT (i.e. passing in a incorrect parameter type).
But having just tried it, I have discovered that the compilation will fail unless the parameter is of the correct type.
So I think that I don't need to find the size of the array in bytes or the size of the UDT in bytes as the paremeter has to be of the correct type for it to compile.