Neuling

String clearing

10 posts in this topic

Hello,

Is there a command to clear the content of a string in rslogix 500?

I'm scanning a barcode string to ST9:0. After that I need to remove the content of that string for the next scan. So far I have copied an empty string into ST9:0 to make it work.

Shouldn't I be able to use the CLR command? When using the CLR command with destination ST9:0 I'm getting an error address must be specified to world level!

 

Thanks for any help

Edited by Neuling

Share this post


Link to post
Share on other sites

A string is a defined type composed of a length then an array of SINTs. I believe the CLR only works on atomic types (sint, int, dint etc). Copying an empty tag is my go-to method for more complex types. You may get some effect by just setting the length to zero but when I tried that I would occasionally see problems with new characters followed by the previous characters. I feel it's best to just clear the whole thing by copying an empty string as you are doing.

Edit - actually I think CLR can be used successfully with timers and counters so my blanket statement is probably false. It would be good to have a CLR with respect to strings.

Edited by b_carlton

Share this post


Link to post
Share on other sites

Try "FLL". Source 0, Dest String.DATA[0], length, string.LEN

Share this post


Link to post
Share on other sites

You can clear just the .LEN element.

Share this post


Link to post
Share on other sites

@pturmel unless Rockwell has changed the behavior, setting the .LEN to zero hides the string from displaying, but the .DATA[x] registers retain their ascii values.  What @PlcAutomation recommends combined with a Mov 0 String.Len totally clears things.

Share this post


Link to post
Share on other sites

Yes, just setting length to zero doesn't rewrite the data bytes, but all logix string instructions honor .LEN and will not use those ignored bytes.  Well-behaved OPC servers will also ignore those bytes.

Share this post


Link to post
Share on other sites

It seems that copying an empty string solves the problem and is simple.  Is there a problem with that method that would require any of the other methods discussed here?

Share this post


Link to post
Share on other sites

You have to ensure the empty source string stays empty.  Marking it as read-only or a constant is probably sufficient.

Share this post


Link to post
Share on other sites
21 hours ago, BobLfoot said:

What @PlcAutomation recommends combined with a Mov 0 String.Len totally clears things.

BTW, this can be simplified to just a single FLL targeting the .LEN element with a constant length of 22 42.

{Edit: Whoops!  SLC, not Logix.}

Edited by pturmel
Wrong processor type.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now