Limit use right () left () idea for expansion?

i have this problem
I have a string of 450 characters :
‘LINE1=1;COMMENT_LINE1$nLINE2=2;COMMENT_LINE2$nLINE3=3;COMMENTO_LINE3$nLINEA 4=4;COMMENTO_LINEA4$nLINEA 5=5;COMMENTO_LINEA5$nLINEA 6=6;COMMENTO_LINEA6$nLINEA 7=7;COMMENTO_LINEA7$nLINEA 8=8;COMMENTO_LINEA8$nLINEA 9=9;COMMENTO_LINEA9$n LINEA 10=10;COMMENTO_LINEA10$nLINEA 11=11;COMMENTO_LINEA11$nLINEA 12=12;COMMENTO_LINEA12’;

I LIKE SEPARATION THIS

LINE1=1;COMMENT_LINE1$n

LINE1 PARAMETER
1 VALUE
COMMENT_LINE1 comment

i have problem separation this string because the limit STANDARD - left() RIGHT()

Output string (max. 255 characters)

do you have idea??

i like this result but with this limit is not possibile when the string is very long

this is the code

image

thank you for support

Hi,

as I know, the cause for the limitation of LEFT() and RIGHT() is because of the definition of LEFT() and RIGHT() in IEC61131, and because this functions get the string variables into the function code as call by value, not as call by refererence (pointer / address).
Therefore some limit has to be set, and even it would be a higher limit, there would be usecases that go beyond it.

So I think you need to implement your own “parser” for that usecase. The’re several different possibilities to do that, he’re 2 ideas:

Loop through the whole string character by character, copy each character to the result memory if it’s not a separator character, and switch to the next result string (next element of your structure, or next array element) depending on the separator found (doing so, LEFT and RIGHT aren’t needed).

“Cutting down” the input string: using only FIND and LEFT to identify the next separator, copy the substring to your result string, and then remove the already found and copied part by doing a stringcopy with start address = string address + found separator index.
Doing so for example in a loop, LEFT and FIND can be used with the “cutted off” string and will always find the next character of interest.

Unfortunately I haven’t a already prepared sample to explain better what I mean.
But nevertheless, hopefully it helps a bit.
Best regards!

Hi again Emanuele @c580527 ,

for the first idea I created a demo program.
It loops byte by byte trough the whole string and decides by the character found, where to copy the next byte(s). It uses address arithmetic and reference variables to copy from the big input string to the right array elements.
(please be aware that it uses a loop over the whole string, so for veeeery large strings it could lead to cycle time issues.)

To start the demo, just set the CASE variable “uParseIt” to 1.
Before run:

After run:

Here’s the task:
Parser.zip (2.2 KB)

Best regards!

2 Likes

hello Alex…
Thank you for support
I try all … but I think you resolve my problem

1 Like

Hi emanuel, have you found solution for your topic? can you mark the answer that helped you the most?