Author Topic: conditional when using variables  (Read 2077 times)

Offline AnnTerr

  • Newcomer
  • *
  • Posts: 2
    • View Profile
conditional when using variables
« on: March 23, 2022, 01:43:36 AM »
Is there a way to only show the comma if the subject variable is not empty?  This is in my global IPTC template for the description/caption field: {year4} {location}, {subject}
« Last Edit: March 23, 2022, 02:17:17 AM by AnnTerr »

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Re: conditional when using variables
« Reply #1 on: March 23, 2022, 09:21:37 AM »
Is there a way to only show the comma if the subject variable is not empty?  This is in my global IPTC template for the description/caption field: {year4} {location}, {subject}

No, and I'm not sure how I would implement something like that though I'd be open to suggestions on how the user would indicate that the comma is optional, depending on whether the variable that follows it evaluates to something.

-Kirk

Offline AnnTerr

  • Newcomer
  • *
  • Posts: 2
    • View Profile
Re: conditional when using variables
« Reply #2 on: March 24, 2022, 02:33:39 AM »
Hi Kirk,

I can make do with the existing functionality, although I was hoping for a different answer!

As far as how a user would indicate it, would something like an "IIF" function do?   

IIF( Length( {subject} ) > 0,   ","  ,  ""  ), meaning if the variable {subject} is not a zero length string, then write a "," else write an empty string (or do nothing). 

So in my caption area, with the fake logic above, I would write:  {year4} {location}IIF( Length( {subject} ) > 0,   ","  ,  ""  )      {subject}

Thanks again for your quick reply. 

Ann