Page 1 of 1

Fact sentence where Value may or may not exist

Posted: 17 Jul 2016 16:31
by arthurk
I have created a Memorial attribute, and am trying to write a sentence to cover all eventualities. I am using the fields as follows:
Place - location of cemetery etc (eg Anytown)
Value - name or description of memorial (eg Smith family memorial)

The following sentence works reasonably well:
{individual} is named on a memorial <({value})> {place}
but I am struggling to write a sentence that could work without resorting to putting the Value in brackets.

What I would like to see is:
Place only: He is named on a memorial in Anytown.
Place and Value: He is named on the Smith family memorial in Anytown.
Value only: He is named on the Smith family memorial.
(I'm hoping that the Value only definition would also work with websites, eg "He is named on the Roll of Honour website.")

In other words, if the Value exists, I'd like the variable part of the sentence to be "He is named on the" and if it doesn't exist, I'd like it to be "He is named on a memorial".

I've found a few references in the Knowledge Base to limitations on the use of Value, but this is all a bit beyond me. Is what I am looking for actually doable, and if so, can anyone help, please?

Thanks,
Arthur

Re: Fact sentence where Value may or may not exist

Posted: 17 Jul 2016 17:35
by tatewise
Yes, you cannot achieve that with the Template Codes alone and need to use functions.
In this case the =CombineText(...) function is best, because it combines different text with a variable depending on whether it has a value or not. See the Help on Functions for details.
e.g.
{individual} is named on{=CombineText(" the ",%FACT%,""," a memorial")} {place}

The way it works is if the %FACT% has a value then it is combined with " the " and "" otherwise " a memorial" is displayed. In this example %FACT% is synonymous with {value} but Template Codes such as {value} are not currently allowed within Functions. I have a Wish List request to allow them and make such functions more flexible.

That template works with all four eventualities of no value, or value supplied, combined with no Place, or Place supplied.

Re: Fact sentence where Value may or may not exist

Posted: 17 Jul 2016 17:59
by arthurk
Thank you very much, Mike. It would have taken me hours to get there by myself - it's quite some way beyond my current expertise.