Help with variables

Started by novaca, January 17, 2024, 12:42:51 PM

Previous topic - Next topic

novaca

Please advise if it is possible to use a condition when working with variables. Something like if variable "A" has a value return "A", if it doesn't, return variable "B"
Specific example: I want to edit the File Window layout.
The header now shows {File.MD.datecreated|format:DD.MM.YYYY • hh:mm}.
However, if there is a value available for {File.MD.XMP::iptcExt\ArtworkOrObjectAOCircaDateCreated\ArtworkCircaDateCreated\0} I would like it to display this instead.
If this is possible, will it have a noticeable negative effect on performance?

Thank you for your suggestions

Mario

Yes. See hasvalue:Text and combine it with default:Text as shown in the description for hasvalue.
You use hasvalue to test if ArtworkOrObjectAOCircaDateCreated has a value. If is the case, you use the variable and format it as needed. Else the default will be used to output the date created.

{File.MD.XMP::iptcExt\ArtworkOrObjectAOCircaDateCreated\ArtworkCircaDateCreated|default:{File.MD.datecreated|format:DD.MM.YYYY • hh:mm};hasvalue:{File.MD.XMP::iptcExt\ArtworkOrObjectAOCircaDateCreated\ArtworkCircaDateCreated|format:DD.MM.YYYY • hh:mm}}

If hasvalue returns a non-empty value (there is an artwork date), default does nothing. Else it outputs date created.

In a simpler form: {File.Label|hasvalue:Has Label;default:No Label}
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

novaca

Great as always, thank you.
Next time I'll try to search longer and think more :) 
However, I'm still getting lost in the variables...

I think I can skip the final |format:DD.MM.YYYY • hh:mm,
for ArtworkCircaDateCreated I use values like "before 1930" or "spring 1963", 
so there is nothing to format.

Mario

You don't need the formatting for the artwork date if you use free text entries of course.

QuoteHowever, I'm still getting lost in the variables...
This is normal. Variables are mostly really simple, like {File.MD.title} for example.
But if you need more complex things, like conditions and output varying depending on whether or not a tag is filled and custom formatting (like in your case), things will become slightly more complicated.

But that's better, IMHO, than an approach that lets you only do simple things and a "Can't do!" for everything else.
There is enough software, especially smart phone apps, out there that work that way.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

novaca

Quote from: Mario on January 17, 2024, 02:10:44 PMBut that's better, IMHO, than an approach that lets you only do simple things and a "Can't do!" for everything else.
That's exactly why I chose IMatch

Mario

Quote from: novaca on January 17, 2024, 02:22:05 PMThat's exactly why I chose IMatch
:) Spread the word! Let others know how good IMatch is. That's the best marketing I can get.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook