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,565
Hello everyone, I'm new here, I hope someone can help me. I've been trying to install EDS files to my Studio 5000 with the EDS tool installer but...
Replies
3
Views
118
Hi Everyone, I am facing an issue while installing the STUDIO 5000 in my windows 10 PC. During installation I am getting an error that " Error...
Replies
4
Views
186
I am connecting to a remote device. When attempting to upload I receive an error that states: Error: Auto_Functions: The Import was aborted due...
Replies
3
Views
189
Back
Top Bottom