STRSUBSTNO value problem

hi guys,

I’m understand that STRSUBSTNO can use up to 10 values. Currently I’m able to use up to 15 values inside and it’s working fine. I tried to add more values and now it is showing error “Reduce the expression so it is less complex”. Anyone have any idea how to add more value inside or how to separate it into two?

Thanks in advance.

Hi Mathu,

As you know already, then only 10 values are supported. And if you have more you need to replace, then you will have to do it multiple steps.

You could do it like this:

[CODE]
ReplaceText := ‘%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18 %19 %20’;

NewText := STRSUBSTNO(
ReplaceText,
‘Value1’, ‘Value2’, ‘Value3’, ‘Value4’, ‘Value5’,
‘Value6’, ‘Value7’, ‘Value8’, ‘Value9’, ‘Value10’);

FOR i := 20 DOWNTO 11 DO BEGIN
TheStrPos := STRPOS(NewText, ‘%’+FORMAT(i));
WHILE TheStrPos > 0 DO BEGIN // While is required if there are more than one representation of each %
IF TheStrPos > 1 THEN
NewText := COPYSTR(NewText,1,TheStrPos-1) + ‘%’ + FORMAT(i - 10) + COPYSTR(NewText, TheStrPos+3)
ELSE
NewText := ‘%’ + FORMAT(i - 10) + COPYSTR(NewText, TheStrPos+3);
TheStrPos := STRPOS(NewText, ‘%’+FORMAT(i));
END;
END;

NewText := STRSUBSTNO(
NewText,
‘Value11’, ‘Value12’, ‘Value13’, ‘Value14’, ‘Value15’,
‘Value16’, ‘Value17’, ‘Value18’, ‘Value19’, ‘Value20’);

NewText := NewText;[/CODE]

Hi Erik,

Thank you for your reply. It’s works.