A Conditional Postfix Argument

Started by Darius1968, October 29, 2021, 06:55:26 AM

Previous topic - Next topic

Darius1968

Suppose:
{File.MD.cameraname|prefix:<Run FontSize="16pt">;postfix:</Run><Run Foreground='Aqua' FontWeight='Bold'> ~;| ~;</Run>}

Then, the output might look something like this: 
Epson PerfectionV550 |

However, I only want the postfix: clause ( | ), of the statement, to have effect, if the variables - for one or more of the following:  aperture, shutter speed, or  ISO - hold a value.  What functions can I use, to test for this condition? 

Mario

Don't use a postfix. The postfix has a special meaning and is processed after all other variable functions have been processed.
Just use two variables instead.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Darius1968

#2
Okay, this is the full statement, I am currently working with: 

{File.MD.cameraname|prefix:<Run FontSize="16pt">;postfix:</Run><Run Foreground='Aqua' FontWeight='Bold'> ~;| ~;</Run>}{File.MD.aperture|prefix:<Run FontSize="16pt">F ~;;postfix: ~;</Run><Run FontSize="14pt">at ~;</Run>}{File.MD.shutterspeed|value:formatted;prefix:<Run FontSize="16pt">;postfix: ~;</Run><Run Foreground='Aqua' FontWeight='Bold'>| ~;</Run>}{File.MD.iso|prefix:<Run FontSize="16pt">ISO ~;;postfix:</Run>}

..., which gives an output, like:

Camera Make/Model | Aperture "F " at Shutter speed | ISO

As can be seen, the postfix: statements are for the separator - " | ".  So, I can do away, with the prefix:/postfix: statements, but then, how can I redo my statement, so that, the enumeration of the variable separator - " | ", occurs only when the following variables, that are left, indeed, have a value? 

Mario

postfix is special and not suitable for this. You'll have to come up with another solution.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Darius1968

Okay, for the enumeration of the delimiter=' | ', I came up, with a statement, like this one: 

<Run Foreground='Aqua' FontWeight='Bold'>{File.MD.aperture|hasvalue:| }</Run>. 
..., which works!

The statement, given above, either outputs nothing, or it outputs the delimiter=' | ', if there is an aperture value, in the file; It tests for the presence of just on variable - aperture.  Is there a way, that I could test for the presence, of one-or-more variables, in this set:  aperture, shutter speed, or ISO, instead of just being confined to one? 

Mario

I don't see an easy way to achieve this. There is no concat operator for multiple variables. This is not a programming language.
You could concat the tags via a metadata template into an XMP tag and then use that tag in your expression.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Tveloso

Even though it's not possible to test for values across a set of variables, if you do "everything" in the prefix, that eliminates the need to do that (since the prefix of each variable is emitted only when that variable has a value).

So if the Aqua-colored pipe separator is given only in the prefix of the variables following {File.MD.cameraname}, then it will only be included when those subsequent variables have values.  And this also eliminates the need to refer to the variable more than once (first to test it for a value, and again to actually emit its value).

Darius1968, I changed my Filewindow Tip based on the example variable you gave above, and it seems to be working well.  With this variable:

{File.MD.cameraname|prefix:<Run FontSize="16pt">;postfix:</Run>}{File.MD.aperture|prefix:<Run FontSize="16pt" Foreground='Aqua' FontWeight='Bold'> ~; ~;| ~; ~;</Run><Run FontSize="14pt">f/ ~;</Run><Run FontSize="16pt">;postfix:</Run>}{File.MD.shutterspeed|value:formatted;prefix:<Run FontSize="14pt"> ~;at ~;</Run><Run FontSize="16pt">;postfix:</Run>}{File.MD.iso|prefix:<Run FontSize="16pt" Foreground='Aqua' FontWeight='Bold'> ~; ~;| ~; ~;</Run><Run FontSize="14pt">ISO ~;</Run><Run FontSize="16pt">;postfix:</Run>}


...the pipes appear when the variables in the subsequent sections have values, but they do not, when a file only has a Camera Name.

I like that design, and am going to keep it.  Thank you very much for the example variable.

I imagine that there will be an issue in the middle section, if a file should have only one of aperture and shutterspeed, but I'm hoping that those are usually either both there, or both missing.
--Tony

sinus

Quote from: Tveloso on October 30, 2021, 05:25:57 AM

...

Darius1968, I changed my Filewindow Tip based on the example variable you gave above, and it seems to be working well.  With this variable:

{File.MD.cameraname|prefix:<Run FontSize="16pt">;postfix:</Run>}{File.MD.aperture|prefix:<Run FontSize="16pt" Foreground='Aqua' FontWeight='Bold'> ~; ~;| ~; ~;</Run><Run FontSize="14pt">f/ ~;</Run><Run FontSize="16pt">;postfix:</Run>}{File.MD.shutterspeed|value:formatted;prefix:<Run FontSize="14pt"> ~;at ~;</Run><Run FontSize="16pt">;postfix:</Run>}{File.MD.iso|prefix:<Run FontSize="16pt" Foreground='Aqua' FontWeight='Bold'> ~; ~;| ~; ~;</Run><Run FontSize="14pt">ISO ~;</Run><Run FontSize="16pt">;postfix:</Run>}


...the pipes appear when the variables in the subsequent sections have values, but they do not, when a file only has a Camera Name.
...

Here we can see again, that variables are very powerfull!
I use variables very often and have in my Filewindow and Design & Print some very complicated and long variables ... they work simply.  ;D
Best wishes from Switzerland! :-)
Markus