Looking for a method to assign values to STRING tags in Structured Text? It appears that using text in quotes like "String Text" is not possible. I have also experimented with using variables, but I am required to declare which character to assign. Is there a structured text alternative to the COP instruction that allows for specifying the number of elements easily? Your input is greatly appreciated. - Warren
When assigning StringVar1 to StringVar2, consider using the COP() command. If the string lengths differ, adjust StringVar1.LEN accordingly. Also, for StringVar assigned with "StringLiteral", I aim to prioritize this topic.
parse_flower discussed using the COP() command for assigning StringVar1 to StringVar2 in cases where they have the same length. However, if the string lengths differ, adjusting StringVar1.LEN may be necessary. To prioritize StringVar := "StringLiteral", one can consider moving literal INTs or DINTs to specific positions for copying into the string file. This method guarantees a hardcoded implementation in the PLC, suitable for any AB platform. While ladder logic supports this approach, ST programming may vary. Alternatively, safeguard the string file post-manual value configuration by securing it before saving and downloading. Although this may render it "unsearchable" in the logic, using a dummy copy or thorough comments can help document the process effectively.
In an effort to enhance the process of assigning string literals, I experimented with storing the string literal in a variable. This resulted in the following code: `asteststring : STRING := [4, 'test.....'];`. By removing the unnecessary characters, such as '$00s', the string was successfully imported. The number 4 indicates the length of the string, while 'test' represents the actual string content. Incorporating keywords like "test" into the variable name can improve searchability, although this approach may not be suitable for all strings. Consider utilizing COP() to assign the string to the target if needed. Although I did not test this with COP(), I believe it should function properly in both Ladder and ST programming languages. This approach may result in faster execution, more efficient code, and improved readability compared to assigning integer values. However, there is still a need for a more standardized method of assigning strings.
Structured Text offers a plethora of uses, with later versions of Logix now supporting single quoted string literals. This can be seen in the example below where a `STRING` type variable, PLXString, is assigned a value: 'String for PLX31-EIP-ASCII'. Alternatively, one can create constant STRING tags at program scope and then copy them, although this method can be laborious. Various functions like COP can be used for string manipulation, but they may not be the most efficient. It is worth noting that the ability to use string literals is processor-specific rather than dependent on the RSLogix version. For instance, only 5380 processors for CLX and 5069 processors for CompactLogix accept string literals. While testing with a 5580 (L81) processor in v29, it was confirmed that string literals can be used, provided the right processor is in use. In cases where a different processor is being used, more complex methods may be required for string manipulation. If you have any questions regarding Structured Text, feel free to ask. Despite being underutilized in the industry, I have experience writing code in ST.
Larry, thank you for providing exactly what I was searching for. I previously encountered issues while using double quotes and was unsure of the reason behind it. I understand the struggle of promoting new programming languages. Despite advocating for function blocks, many individuals default to ladder logic, even though it may not be the most efficient choice for certain applications. I prefer using Structured Text (ST) in situations like I/O mapping or when a for loop would be beneficial. Function Block Diagram (FBD) may be a more appealing option as it is a visual language, whereas ST can seem intimidating to non-professional programmers due to its resemblance to traditional code. Additionally, the convenient Rockwell feature of "highlight and press F1" for help does not seem to apply to ST, leading me to explore alternative options.
Hey Warren, using STRING types can sometimes be a bit tricky in structured text. You could try using the CONCAT or CONCAT3 instructions to generate strings. If you want to assign a string directly, you can indeed use the ":=" operator with text in quotes like myString := 'String Text'; It should work fine. However, if you need to manipulate it further, declaring each character may be the only way. Unfortunately, there's no direct alternative to the COP instruction in Structured Text where you can specify the number of elements. That's one downside to using ST over traditional ladder logic or function block diagrams.
Hi Warren, it looks like you're undertaking a tricky task! In Structured Text, you should be able to assign a string to a string variable by enclosing the text in single quotes, in your case, it would be 'String Text'. Regarding your question about the COP instruction, I am not certain of an exact alternative. You might consider a FOR loop if you're playing with an array of elements. Of course, this might involve a bit more code, but you can specify the number of elements to process. I hope this provides some direction to your work.
Hey Warren, yes, directly using double quotes for assigning strings like "String text" is generally not supported in structured text. Instead, you can try to use a STRING variable and assign a value to it using := operator. For instance, MyString := 'This is my string'; Alternatively, if you need a method similar to COP instruction, you might want to look into the use of ARRAY of STRING. This allows you to easily manage a number of text strings and assign values appropriately. Hope this helps.
Hey Warren, I believe that you can use CONCAT command in structured text. It merges two strings. Another solution might be using an array of characters and then assigning each element. For large scale usage, perhaps, a custom function block that effectively mimics the functionality of COP instruction could be a way to go. Hopefully this gives you a starting point!
✅ Work Order Management
✅ Asset Tracking
✅ Preventive Maintenance
✅ Inspection Report
We have received your information. We will share Schedule Demo details on your Mail Id.
Answer: Answer: In Logix5000 Structured Text, you cannot directly assign values to STRING tags using quotes like "String Text". You may need to explore alternative methods such as using variables or specific instructions.
Answer: Answer: To specify the number of elements when assigning values to STRING tags in Structured Text, you may need to look for alternative instructions or methods that allow for more flexibility in defining the length of the string.
Answer: Answer: If you are looking for an alternative to the COP instruction in Logix5000 Structured Text for assigning values to STRING tags, consider exploring other instructions or custom functions that provide more control over the assignment process.
Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.