Author Topic: Conditional Text  (Read 4432 times)

Offline IanGoldstein

  • Member
  • **
  • Posts: 98
    • View Profile
Conditional Text
« on: June 19, 2007, 02:32:34 PM »
Would it be possible to add "conditional text" in text fields? In other words, the ability for some text and/or variables to be included based on simple conditions.  For example, when using the following text with variables...

     {ss} sec at f/{f} ISO {iso} EV {comp}

...it would be nice to exclude the "EV {comp}" portion when {comp} is zero.  I realize a full "iif()" style function would probably be overkill and a bit involved to implement. However, perhaps a simple conditional block which tests a variable for a non-zero/non-blank value. For example...

     {ss} sec at f/{f} ISO {iso} {if:comp}EV {comp}{endif}

...would result in a test of the {comp} variable; when it is non-zero the "EV {comp}" text is included, otherwise it is skipped. Obviously various other syntaxes would work as well (or better), but would probably require variable name parsing to allow for nested delimiter charcters.  In addition, much more involved conditional tests could always be added in the future (if needed). However, for now a simple {if} conditional block, perhaps along with an {ifnot} conditional block, could be a valuable addition to PM.

Some other examples where this could be of value...

     {if:tag}TAGGED{endif}
     adds "TAGGED" to slideshow text for images that are tagged

     (c){username}{if:usercompany}/{usercompany}{endif}
     copyright with username and optional company name

     {city}{if:state}, {state}{endif}{if:country}, {country}{endif}
     displays formated "city, state, country" allowing for optional state and country fields
     
     ingestpath\{if:raw}RAW\{endif}prefix{seq}
     allows RAW files to be injested to a subdirectory, if a {raw} variable existed which equals 1 when a file is a raw type  ;)

Thanks,
Ian

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Re: Conditional Text
« Reply #1 on: June 19, 2007, 03:07:42 PM »
Ian,

Would it be possible to add "conditional text" in text fields? In other words, the ability for some text and/or variables to be included based on simple conditions.  For example, when using the following text with variables...

     {ss} sec at f/{f} ISO {iso} EV {comp}

...it would be nice to exclude the "EV {comp}" portion when {comp} is zero.  I realize a full "iif()" style function would probably be overkill and a bit involved to implement. However, perhaps a simple conditional block which tests a variable for a non-zero/non-blank value. For example...

     {ss} sec at f/{f} ISO {iso} {if:comp}EV {comp}{endif}

...would result in a test of the {comp} variable; when it is non-zero the "EV {comp}" text is included, otherwise it is skipped. Obviously various other syntaxes would work as well (or better), but would probably require variable name parsing to allow for nested delimiter charcters.  In addition, much more involved conditional tests could always be added in the future (if needed). However, for now a simple {if} conditional block, perhaps along with an {ifnot} conditional block, could be a valuable addition to PM.

Some other examples where this could be of value...

     {if:tag}TAGGED{endif}
     adds "TAGGED" to slideshow text for images that are tagged

     (c){username}{if:usercompany}/{usercompany}{endif}
     copyright with username and optional company name

     {city}{if:state}, {state}{endif}{if:country}, {country}{endif}
     displays formated "city, state, country" allowing for optional state and country fields
     
     ingestpath\{if:raw}RAW\{endif}prefix{seq}
     allows RAW files to be injested to a subdirectory, if a {raw} variable existed which equals 1 when a file is a raw type  ;)

I am planning to add conditional expressions in a future version of Photo Mechanic.  I'm not sure what version it will first appear in however.

-Kirk