* Using loop index in fact templates

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile. If your question fits in one of these subject-specific sub-forums, please ask it there.
Post Reply
avatar
gasav
Newbie
Posts: 3
Joined: 05 Jan 2018 08:51
Family Historian: V6.2

Using loop index in fact templates

Post by gasav »

Hello all!

I am trying this expression in Sentence Template for "Residence" fact:

{date} {%CUR_PRIN.NAME[1]:FIRST%} lived in /{_place}/< with {%FACT._SHAR[1+]>NAME[1]:FIRST%}>

I want to get a result like this:
From December 2013 to September 2014 John lived in /London/ with Sarah, Peter, Daniel.
But loop (_SHAR[1+]) don't work, so I see that as result:
From December 2013 to September 2014 John lived in /London/ with Sarah.

What am I doing wrong?

My FH version is 6.2.5.
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Using loop index in fact templates

Post by tatewise »

Welcome to the FHUG.

The short answer is that the [1+] looping index only applies to Diagram Text Schemes.
See how_to:understanding_data_references|> Understanding Data References and follow its cross-reference to the FH Help > Using Family Historian > Advanced Topics > Understanding Data References and its Advanced Indices advice.

Even if it did loop, the comma & space separators that you require would not be included using your template.

So you need to use the =CombineText(...) function multiple times :-
{=CombineText( " with ", %FACT._SHAR[1]>NAME:FIRST%, "" ,"" )}
{=CombineText( ", ", %FACT._SHAR[2]>NAME:FIRST%, "", "" )}
{=CombineText( ", ", %FACT._SHAR[3]>NAME:FIRST%, "", "" )}
{=CombineText( ", ", %FACT._SHAR[4]>NAME:FIRST%, "", "" )}
{=CombineText( ", ", %FACT._SHAR[5]>NAME:FIRST%, "", "" )}

It would be extremely tricky to get an and inserted prior to the last witness.

As a newcomer I advise you study how_to:key_features_for_newcomers|> Key Features for Newcomers and follow its links into further [kb]|[/kb] topics.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
gasav
Newbie
Posts: 3
Joined: 05 Jan 2018 08:51
Family Historian: V6.2

Re: Using loop index in fact templates

Post by gasav »

Hello, tatewise!

Thank you for so detailed answer!

I have already read "Understanding Data References" and related chapters about functions. And I've tried to use the method you recommended. But there are two circumstances:

1. I don't understand how to exclude self-person when I use an expression for a witness. For a witness, I want to list first names of principal and all other witnesses exclude the current person.

2. I noticed the standard tag {other=Resident}. This tag works as I want with the exception of name format and format of comma & space separators. I want to list for each person only first name and I want to change "and" for another string. It seemed to me that if there is a standard tag that creates loop then there could be loop method for fact templates.
Apparently, I'm wrong?
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Using loop index in fact templates

Post by tatewise »

If you have read Help > Using Family Historian > Advanced Topics > Understanding Data References, then under its Advanced Indices you will have seen that looping indexes only apply to Diagram Text Schemes:-
Finally, there is also the looping index. This is only used in text templates (see Understanding Text Templates) in text schemes ... Looping indices only work within text templates in text schemes.
  1. The way to exclude the Principal is don't add them as a Witness.
    Excluding the Principal using conditional functions in Sentence Templates is going to be virtually impossible, but you are welcome to try.
    You are currently focussing on the Principal Sentence Template but must also consider the Witness Sentence Template.
  2. There is no looping method for Sentence Templates.
    To define a final separator between Witnesses use:
    {=CombineText( " with ", %FACT._SHAR[1]>NAME:FIRST%, "" ,"" )}
    {=CombineText( TextIf( Exists( %FACT._SHAR[3]%), ", ", " & " ), %FACT._SHAR[2]>NAME:FIRST%, "", "" )}
    {=CombineText( TextIf( Exists( %FACT._SHAR[4]%), ", ", " & " ), %FACT._SHAR[3]>NAME:FIRST%, "", "" )}
    {=CombineText( TextIf( Exists( %FACT._SHAR[5]%), ", ", " & " ), %FACT._SHAR[4]>NAME:FIRST%, "", "" )}
    {=CombineText( TextIf( Exists( %FACT._SHAR[6]%), ", ", " & " ), %FACT._SHAR[5]>NAME:FIRST%, "", "" )}

    i.e. If next Witness exists, then use ", " else use " & " as separator.
  3. All the above only works because all Witnesses have the same %FACT._SHAR[n].ROLE% of Resident.
    If there were multiple ROLE values (as with the Marriage Event) then it becomes virtually impossible.
Do you have some grand plan for customising Narrative Sentences of which this is just a start?
e.g. Are you hoping to translate into a foreign language?

BTW: Sentence Templates are not equivalent to a general purpose report writer, and there are many components that cannot be customised.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
gasav
Newbie
Posts: 3
Joined: 05 Jan 2018 08:51
Family Historian: V6.2

Re: Using loop index in fact templates

Post by gasav »

Hello, tatewise!
Thank you again!
The way to exclude the Principal is don't add them as a Witness.
I wrote about Witness Sentence Template too. I don't want to get a result like: "Jane lived with John, Jane & Kate". But I understood how to make a function for check it. This is cumbersome, but must works.
e.g. Are you hoping to translate into a foreign language?
Yes, I want to localize reports and messages because English isn't native language for me and my family. Maybe there is the more simple method?
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Using loop index in fact templates

Post by tatewise »

I am sorry to say that using Sentence Templates to translate into a foreign language is NOT possible.
Many users have tried before and failed:
Non-English sentences (12564)
Hebrew Language Support (9790)
Narrative reports - changing language (8127)

There is Wish List item Ref 541Narrative Sentence options and Reports for other languages that you can Vote for.

Calico Pie have said "This is an area we hope to address in more detail in a future release, but we do not currently have a time scale for doing so."

I suggest you report the problem to Calico Pie using how_to:about#problem_reporting|> Problem Reporting.

In the meantime, try using Save Report As > PDF File and use one of the many free online translation services such as https://translate.google.com/.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Post Reply