Clearing Out a String Tag

recondaddy

Member
Join Date
Apr 2006
Location
Atlanta, GA
Posts
77
Is there an instruction in RSLogix5000 for clearing out a string tag? I've tried COP with a zero as the source and the string tag as the destination with a length of 1. I get
"COP, Operand 0: Invalid kind (tag, literal, or expression) of operand."

I've also tried MOV with a zero as the source and the string tag as the destination. With that, I get
"MOV, Operand 1: Invalid type."

I can't really use DEL because I never know the exact number of characters that the string will contain.

Anyone have any guidance?
 
Yep. I figured it out. Didn't realize that you needed to write a zero to the .DATA[0] element of the string tag:

MOV
Source: 0
Dest: MyString[1].DATA[0]

Or, I guess a CLR would work just as well. Thanks for your help.
 
recondaddy said:
I've also tried MOV with a zero as the source and the string tag as the destination. With that, I get
"MOV, Operand 1: Invalid type."

The error message is telling you exactly what you're doing wrong, that is, trying to move a numeric value into a string. If you'd use a null string (string = "") as operand 1, I bet it would work.
 
CLR or MOV will only clear one character. To clear all characters from the string use FLL.

FLL,0,string_tag.data[0],x

where x is the length of the string.
 
"MOV, Operand 1: Invalid type."

The error message is telling you exactly what you're doing wrong, that is, trying to move a numeric value into a string. If you'd use a null string (string = "") as operand 1, I bet it would work.
How does one get a null string when there are no String Literals? Just a string that was never assigned anything


P.S. AB Sucks, Long Live IEC61113-3
P.P.S. I have to us AB :cry:I hate it so much. :cry:


P.P.P.S. I was in High School when this thread was started...
 
FLL,0,string_tag.data[0],x

where x is the length of the string.

Adding to that you can use FLL with 0 as the source, the STRING as the destination, and 1 as the length. It will fill the LEN and every SINT with 0 and blow the whole lot away.


How does one get a null string when there are no String Literals? Just a string that was never assigned anything
You make one. If you NEED a blank string, create gsBlank as a STRING, leave it empty, and then make it a constant.
 
Last edited:
Adding to that you can use FLL with 0 as the source, the STRING as the destination, and 1 as the length.

:facepalm:

All this time (literally decades) I've been doing it the "hard" way by addressing both the LEN and DATA.

I think we might be seeing more zombie threads this week than usual. But hey, never too old to learn.
 
All this time (literally decades) I've been doing it the "hard" way by addressing both the LEN and DATA.


I have been working on so many serialisation projects over the last few years that doing things with strings that a PLC should never have to do has become commonplace :(



#Databases
#Industry4.0
#BigData

:mad:
 
Im with Bernie. I use a blank string and COP.,its probably not the most smallest use of memory but its easy and memory is cheap lately
 
So apparently at least in v30+ this is perfectly valid......


Which means RS 5000 does have string literals.......


Which mean all these other hacks are useless.

2020-03-18_17-15-42.png
 

Similar Topics

Hello all - I have a string tag that is a member of a UDT that I would like to clear within a Structured Text routine - but cannot seem to get it...
Replies
2
Views
7,327
RSlogix5000 - Here is what I would like to accomplish and what I am running into. Currently this is a scanner ASCII gateway to PLC set up. A)...
Replies
9
Views
3,969
Hi I am using a SLC 500 and a lot of string handling. I need to copy a NULL value to a string table eg. ST16:0. How do I do it?
Replies
2
Views
5,089
I'm online with a 90-30 using PAC ME 9.8 No one has gotten online with this PLC for many years and the the I/O fault table has a total of 1209...
Replies
6
Views
2,988
Using an L81 - I have the arrangement below that will try the Ethernet Radio first and if that fails use the Cellular Radio. The Failover works...
Replies
16
Views
3,363
Back
Top Bottom