Studio 5000 COP (Copy)

einnh

Lifetime Supporting Member
Join Date
Mar 2014
Location
New England
Posts
275
Question about COP and UDT's in Studio 5000.

I have a UDT structure with various data types that is reporting (according to the properties tab in the UDT) to be 252 bytes.

If I wanted to copy this entire UDT variable into another variable with the same UDT would 252 be the number I enter at the end of the instruction?

Code:
cop(variablea,variableb,252);

The help file for COP uses the term 'elements' for what to put as the last input but it also shows a calculation for 'bytes' so I'm not sure exactly what they are referring to.
 
The COPy command won't write past the end of the destination. But lets say you have an 8 element array being copied to a 10 element array of the same type. If your length is 10 then, once the COPy has copied the first 8 elements it will continue picking up whatever garbage is past the end, in memory, of the source array. The byte count is basically a sanity check. It is even more important if you are copying from one type to a different type.
 
bernie_carlton said:
The byte count is basically a sanity check

Good thing the PLC is only checking it's own sanity and not that of it's programmer, or there'd be a whole lot more faulted PLC's out there ;)
 

Similar Topics

Am I losing it? Is it not possible to COP a UDT to another UDT in a function block routine? PLEASE HELP!
Replies
4
Views
1,546
Hi Everyone. Not posted on here for a long time, but I am hoping someone can help me. I am doing a differential pressure calculation in a L27ERM...
Replies
16
Views
346
Hi, how do I convert 2x Integer registers to a Real? The two integers are from Modbus registers that contain a floating point value, I need to...
Replies
2
Views
125
What is the best way to extract the hour and minute from the register that comes from Yaskawa VFD. In studio 5000 I have a register saved as INT...
Replies
3
Views
129
I have an Allen Bradley temperature switch that I am trying to use in studio 5000. I am getting the message "Unable to interpret the IODD file"...
Replies
0
Views
80
Back
Top Bottom