Hello PLCnext Community!
I’m reaching out to discuss and suggest an improvement for string handling in PLCnext. As many of you might agree, working with strings in Structured Text can sometimes feel like you’re trying to solve a Rubik’s Cube – it’s doable, but a straightforward solution would be much appreciated!
Currently, when we want to create a string like “Hello PLCnext community, it’s [dayCountDown] days till the new month starts”, we have to jump through a few hoops. Here’s what we do now:
- Use
TO_STRINGto convert variables to strings (and hope it doesn’t argue about the data types). - Use
CONCATto put together multiple strings, which can feel like trying to fit a square peg in a round hole if you’ve got more than two strings.
Here’s an example of the current method:
fullString := CONCAT('Hello PLCnext community, it’s ', CONCAT(TO_STRING(dayCountDown, '{0}'), ' days till the new month starts'));
Wouldn 't it be wonderful if we could simplify this process? My suggestion is to introduce direct string concatenation with the + operator or, even better, support for template literals similar to those in JavaScript with backticks and ${variable}.
Imagine the simplicity and clarity we could achieve:
fullString := `Hello PLCnext community, it's ${dayCountDown} days till the new month starts`;
This change would not only save time and reduce code complexity but also bring a smile to our faces, much like when you find an extra cookie in your cookie jar! What do you all think? I believe this could be a small change with a big impact on our day-to-day programming experience when using strings with variables in it. Looking forward to hearing your thoughts and insights! Best, Michel
