photools.com Community

IMatch Discussion Boards => General Discussion and Questions => Topic started by: PandDLong on May 19, 2025, 08:48:48 AM

Title: Using XAML code in a 'foreach' formatting function
Post by: PandDLong on May 19, 2025, 08:48:48 AM

I am trying to insert a line break into a Text Overlay in the Batch Processor while using the 'foreach' formatting function. It is inserting the XAML code for a line break but it isn't interpreting the code.

This expression:  {File.MD.city|foreach:{value} {remaining|is:0,,+;pereplace:+==<LineBreak/>}}

gives:   City 1 <LineBreak/>City 2

I have tried various other ways to insert the <LineBreak/> but always get the same result.

Am I doing this wrong?  
Or am I expecting too much  (IMatch variables already do a lot) and XAML markup can't be used inside a 'foreach' loop?    

Thanks for the help

Michael

Title: Re: Using XAML code in a 'foreach' formatting function
Post by: Mario on May 19, 2025, 09:11:59 AM
Where you use the variable, wrap it into

<TextBlock>Your variable here</TextBlock>

Title: Re: Using XAML code in a 'foreach' formatting function
Post by: PandDLong on May 20, 2025, 07:14:55 AM

I still couldn't get it to work within a 'foreach' loop.

But, that is okay, there is another way.  My text overlay only has room for 4 entries (and it should never be more) so I will just use the 'index' function and manually enter the variables 4 times using index numbers 0,1,2 and 3 with a <LineBreak/> after each.



Michael
Title: Re: Using XAML code in a 'foreach' formatting function
Post by: Mario on May 20, 2025, 09:07:09 AM
Very well. There is a complexity limit for IMatch and mixing XAML with foreach loops is maybe too much.
Title: Re: Using XAML code in a 'foreach' formatting function
Post by: sinus on May 20, 2025, 12:09:06 PM
Quote from: PandDLong on Today at 07:14:55 AMI still couldn't get it to work within a 'foreach' loop.

But, that is okay, there is another way.  My text overlay only has room for 4 entries (and it should never be more) so I will just use the 'index' function and manually enter the variables 4 times using index numbers 0,1,2 and 3 with a <LineBreak/> after each.



Michael

I am not sure, if I understand this correctly.
But, Michael, I tried this with Design&Print, and it works not, like you wrote.

Perhaps you could try some "tricks", I tried the following code

<TextBlock Width="700" TextWrapping="Wrap" FontFamily="Adobe Garamond Pro" FontSize="42pt" xml:space="preserve">{File.MD.city|foreach:{value}{remaining|is:0,,aaa;pereplace:aaa==                                    }}</TextBlock>
where the Width at the beginning and the spaces at the end (for replace) are important values to "play".

I get with these city-names:

Lana; New York; Bern; Paris; London; Marseille; Oberentfelden AG; Ruukki

the output in the attachement. But I do not often use the Batch processor, hence I do not know, if this could help.