Unequal string copy

bernie_carlton

Lifetime Supporting Member + Moderator
Join Date
Apr 2002
Location
Yakima, Washington
Posts
6,413
I'm using Compactlogix and RSLogix5000.

The external equipment vendor has a defined string shorter than the standard one (64 character versus 82 characters).

If a COPY is done from a shorter string to a standard string the last 18 characters of the standard string will probably end up as garbage.

Do subsequent string commands look at characters beyond those defined by the .LEN value or should I specifically null out the last 18 characters of the standard string just to be sure?
 
According to TN 50650 Custom STRING data types and copy to/from standard STRING tags (Access Level TechConnect) is possible to copy characters back and forth.

However, you're right about the garbage at the end of the string. I did a little test on Emulate and the COP instruction doesn't clear the longer string before copying the data from the shorter one. If you inspect the DATA array you will see some garbage at the end.

I think you can copy an empty string to your destination strings before executing another COP instructions involving short strings.
 
Actually I've decided to COPY an 18 element SINT array (all set to 0) into the final 18 character positions immediately after the string copy. It's only one place in the program so fine.

The 'garbage' would be whatever is in the 18 SINTs (4 1/2 DINTS - whatever) following the shorter string in memory.

And thanks for the Knowledgebase pointer. But copying an empty string in BEFORE the short -> standard copy is rather useless. The cleanup has to occur AFTER the string copy.
 
Last edited:

Similar Topics

I'm trying to compare strings in Studio 5000 on an Allen Bradley 1769-L33ER and came across this weird incorrect string comparison. Neither of the...
Replies
10
Views
237
Hello, I have recently been having trouble assigning a string tag to some characters in rs logix 5000. I initially though you could just do...
Replies
3
Views
109
Hello everyone, Wondering if anybody can help me with this: I have a CompactLogix processor running a little robot cell. Every 200 cycles...
Replies
8
Views
195
All, I am trying to reset timers when a Work Order change occurs. The Work Order comes in as a string and I am comparing it to a tag...
Replies
2
Views
122
Hello, I am using studio 5000 pro and am trying to figure out the structured text. Here's my scenario: An operator scans a barcode, the barcode...
Replies
15
Views
395
Back
Top Bottom