CLX 5000 Nullifying a String

robertmee

Lifetime Supporting Member
Join Date
Feb 2008
Location
NC
Posts
2,048
Is it me or does String handling in the CLX leave something to be desired ;)

In any case I have a routine that builds a date/time string and moves into to an array for historical purposes. After the move I want to reinitialize the string to null. The simplest way I found was to create a String Tag, populate it with null ('') and do a CONCAT Null_tag Null_tag DateTime_tag. Is there something better?

BTW, don't use CLR on a string....Put RSLogix5000 into an infinite loop and locked it up solid when it tried to accept the rung.
 
I too use a null string but just use the COPy command to move it to the sting I want to clear. In some cases I've just set the LEN parameter to zero.
 
Last edited:
robertmee said:
Is it me or does String handling in the CLX leave something to be desired ;)

In any case I have a routine that builds a date/time string and moves into to an array for historical purposes. After the move I want to reinitialize the string to null. The simplest way I found was to create a String Tag, populate it with null ('') and do a CONCAT Null_tag Null_tag DateTime_tag. Is there something better?

BTW, don't use CLR on a string....Put RSLogix5000 into an infinite loop and locked it up solid when it tried to accept the rung.

I think moving a 0 into the String.LEN will accomplish the same thing
 
So if setting the the LEN to 0 will make it appear empty, does that mean the AB strings are not null terminated?

I assume the data is still there it's just not accessible as a string anymore. If you access .Data it would still be there right?
 
Moving a 0 into the LEN will not clear the data array. If you put 0 in to the LEN, then change it back to the original value, the data is still there.
 
Setting the .LEN of a String to zero does not remove any of the values from the .Data[x] array, it just makes them invisible. Changing the .LEN to a nonzero length makes them visible (to a user viewing the String in the Tag Database, as well as to String instructions) again.

To clear a string, I move a 0 to the .LEN subelement and then File Fill (FLL) with a source of 0 and the Stringname.Data[0] destination. The Length of the File Fill be be whatever Length the String is (default 82 characters).

Two instructions, but they work fine.
 
Moving a 0 into the LEN will not clear the data array. If you put 0 in to the LEN, then change it back to the original value, the data is still there.

Setting the .LEN of a String to zero does not remove any of the values from the .Data[x] array, it just makes them invisible. Changing the .LEN to a nonzero length makes them visible (to a user viewing the String in the Tag Database, as well as to String instructions) again.
Thanks guys that's what I was assuming.




To clear a string, I move a 0 to the .LEN subelement and then File Fill (FLL) with a source of 0 and the Stringname.Data[0] destination. The Length of the File Fill be be whatever Length the String is (default 82 characters).

Two instructions, but they work fine.


but if you use a FLL, With Source: 0, Length: Stringname.LEN, Destination: Stringname.Data[0]. You shouldn't need to Set .LEN to 0 right? Or is .LEN not the same as the number of element in the .data char array?


but regardless as long as you use the same instruction every time you should end up with a completely null string right.

Code:
string1 = "BLAH"

FLL(Source: 0, Length: string1.LEN, Destination: string1.Data[0])


would null, elements 0,1,2,3 so you would end up with all 82 elements as null. Right?



Also

I will assume then that AB strings are not null character terminated.
 
Last edited:
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.


But....... This doesn't null all the chars in the string. So I guess it depends on what you want. But the .Data array is only accessible as a SINT array so...... Really it doesn't because who cares what is in there.

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

Similar Topics

Hi All, While building the offline project for CLX 5580 with 1756 Rack I/O, I noticed that there is a field for "Series" and "Version" for some...
Replies
2
Views
719
Hi All, I am relatively new to CLX/PLC but not new to the automation field, to give you some perspective. In Studio 5000 Logix designer, when you...
Replies
6
Views
936
Dear all, may be people here wants to share experiance about interconnection between two controllers AB 1756-L73, as per this attachment pic, im...
Replies
4
Views
2,884
I ned to send data from a ML 100 to a CLX 5000. Can this be done with a msg instruction or is there a better way? thanks
Replies
3
Views
2,648
Hi everybody, Is there anyway to open some specifics Socket on Ethernet (192.168.1.37:21000) with Contrologix 5000 like in Siemens S7. I need to...
Replies
5
Views
2,781
Back
Top Bottom