Page 1 of 1

Text Schemes in Diagrams

Posted: 13 Sep 2014 16:10
by wulliam
Hi,

I'm having my first serious attempt at customising the text in diagrams...and have been scratching my head for the past couple of hours.

The following is supposed to:
1) Output "Born: " if there is any birth data - either date or place
2) Output the birth date
3) Output ", " IF there is a birth date AND and birth place, otherwise output ""
4) Output birth place
5) Output "."

=ExistsText(%INDI.BIRT%,"Born: ")%INDI.BIRT.DATE:COMPACT%=TextIf(Exists(%INDI.BIRT.DATE%) and Exists(%INDI.BIRT.PLAC%),", ")%INDI.BIRT.PLAC:SHORT%.

It sort of works but, if there is no date it is determined to put a ", " before the place.

In addition, I also want "." to appear after the date if there is no place recorded...

I'm also wanting this for baptism, marriage, death and burial - but this one example should suffice.

Thanks for taking the time,

Kind regards,
William

Re: Text Schemes in Diagrams

Posted: 13 Sep 2014 18:01
by tatewise
Text Templates are cleverer than you realise.

To force the comma ", " and full-stop "." in the correct conditions needs:

Born: %INDI.BIRT.DATE:COMPACT%=ExistsText(%INDI.BIRT.DATE%,ExistsText(%INDI.BIRT.PLAC%,", "))%INDI.BIRT.PLAC:SHORT%=ExistsText(%INDI.BIRT%,".")

The first ExistsText nested pair will output ", " only if both DATE & PLAC exist.
The last ExistsText will ouput "." if the Birth Event exists.

Re: Text Schemes in Diagrams

Posted: 13 Sep 2014 18:02
by Jane

Code: Select all

=ExistsText(%INDI.BIRT%,"Born: ")%INDI.BIRT.DATE:COMPACT%=TextIf(IsSet(%INDI.BIRT.DATE%) and IsSet(%INDI.BIRT.PLAC%),", ","")%INDI.BIRT.PLAC:SHORT%=TextIf(Exists(%INDI.BIRT%),".","")
Note the use of IsSet rather than exists, with Date fields they often exist and are blank when using the Fact Tab or importing. You can check this on the All Tab, using IsSet checks they have a value in them.

In text schemes leading and trailing text is conditioned on the previous expression, so a simple . will be dropped when there is no place.

Re: Text Schemes in Diagrams

Posted: 13 Sep 2014 18:03
by Jane
I think Mike and I worked on this at the same time, just goes to prove there is always at least two ways to do everything in FH. :D

Re: Text Schemes in Diagrams

Posted: 13 Sep 2014 18:08
by wulliam
Thanks to you both - there are indeed more than one ways of skinning the proverbial cat.
Now to try to get the other events functioning in the same way :)

Thanks again,
William

Re: Text Schemes in Diagrams

Posted: 13 Sep 2014 18:55
by wulliam
I've used Jane's version and it's worked very nicely for Death and Burial. I've even managed to adapt it for Marriage.
However, for some reason I'm getting an error with the equivalent statement for Baptism. I'm using this:

=ExistsText(%INDI.BAPT%,"Baptised: ")%INDI.BAPT.DATE:COMPACT%=TextIf(IsSet(%INDI.BAPT.DATE%) and IsSet(%INDI.BAPT.PLAC%),", ","")%INDI.BAPT.PLAC:SHORT%=TextIf(Exists(%INDI.BAPT%),".","")

I don't understand why this fails when the others work - what am I missing??

Re: Text Schemes in Diagrams

Posted: 13 Sep 2014 19:06
by tatewise
That is because the Baptism tag is BAPM not BAPT.

You should use the <<Insert > Data Reference Assistant to get the basic data ref and then adapt the Template.

Re: Text Schemes in Diagrams

Posted: 13 Sep 2014 20:44
by wulliam
It's so simple when you know how...I've a lot to learn - thanks for your help tonight!