What's the opposite of 'hasvalue'?

Started by loweskid, February 27, 2021, 08:00:57 PM

Previous topic - Next topic

loweskid

I have succesfully imported attributes into over 3000 files using the CSV Importer (brilliant!) and now I want to display an icon in the file display header for those files that have attributes.

I'm using the expression -

{File.AT.Alamy Info.Additional Info|hasvalue:;default:<Image Source='file://C:\ProgramData\photools.com\IMatch6\vl_icons\atts.png'></Image>}

but this displays an icon in the files that don't have attributes.  How can I invert it?

I've looked in the help files but my brain is getting addled now and I'm sure I'm missing something simple.

Mario

You have the two options: hasvalue (when there is a value) and default (when there is no value).
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

loweskid

#2
Sorry but I'm still struggling with this.  If I swap it round so that hasvalue is before default then it shows in the correct file window but displays as text instead of the icon.

In the attached screenshots the file on the left has attributes while the one on the right has none.

This displays the icon correctly but in the wrong file (atts01) -

{File.AT.Alamy Info.Additional Info|hasvalue:;default:<Image Source='file://C:\ProgramData\photools.com\IMatch6\vl_icons\atts.png'></Image>}


This displays in the correct file but shows the text of the file path instead of the actual icon, even though the file path is exactly the same (atts02) -

{File.AT.Alamy Info.Additional Info|hasvalue:<Image Source='file://C:\ProgramData\photools.com\IMatch6\vl_icons\atts.png'></Image>;default}


In the second example, if I replace the file path with simple text it displays correctly (atts03) -

{File.AT.Alamy Info.Additional Info|hasvalue:This file has attributes;default}


What am I doing wrong?

Mario

#3
Consider this example: If a file has a title, I want to display YES, else NO.
I use this variable:

Title: {File.MD.title|hasvalue:YES;default:NO}

This produces either:

Title: YES

or

Title: NO

depending on whether or not the title metadata tag contains data. The same works with Attribute variables, for example:

Customer: {File.AT.Sales.Customer|hasvalue:YES;default:NO}

Shows YES when the file has data for the Customer Attribute in the Sales set, else NO.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

loweskid

I understand the logic and, following your example, it works correctly when using text.  However, if I replace the text with the image file path it doesn't display the icon if the attribute has value.

For example - if I use the same text on either side of the argument then it will display the same result regardless of whether the attribute has value or not.  So this -

{File.AT.Alamy Info.Additional Info|hasvalue:YES;default:YES}

correctly displays YES in both file windows - see image atts04.jpg.

So if I replace the 'YES' with the image file path then logically it should display the icon whether or not there is value in the attribute - but it doesn't.  So this -

{File.AT.Alamy Info.Additional Info|hasvalue:<Image Source='file://C:\ProgramData\photools.com\IMatch6\vl_icons\atts.png'></Image>;default:<Image Source='file://C:\ProgramData\photools.com\IMatch6\vl_icons\atts.png'></Image>}

displays the icon if there is no value but displays as text if there is value - see image atts05.jpg

This is what I don't understand.

Mario

Keep an eye on how variables have to escape markup-breaking content to avoid the File Window layout breaking.
And your variable uses < and >, which have special meaning in markup and are thus escaped for good reasons.

Please se Using Custom Icons in the File Window for more information.

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook