* Help with text expression
- phillip_leslie
- Gold
- Posts: 21
- Joined: 30 Jun 2022 07:49
- Family Historian: V7
- Location: Huddersfield, West Yorkshire, UK
Help with text expression
Hi all,
I am struggling with a text expression for the sentence of Marriage facts.
I have recorded some marriages with only one principal, sometime the Groom or Bride depending on the information that I have. In these cases I am very uncertain of the other persons name and record the possibilities in the notes field rather than creating another individual.
I would like to construct a summary template sentence which supports these two scenarios where the groom is the principal:
Marriage-1 with two individuals: Groom, Bride & Notes - sentence "Marriage: Groom-Name & Bride-Name ; Notes"
Marriage-2 with only principal1: Groom & Notes - sentence "Marriage: Groom-Name & Notes"
Sort of on the lines of:
"Principal1-name & <(principal2-name if there is a principal2 otherwise Notes)> <; (Notes if there is a principal-2)>"
The only conditional test I can find is using =TextIf() however this only appears to support static text in the last two expressions, I cannot find a way of entering =TextIf(no-exists...) and it will not support the following:
{=TextIf(exists(%CUR_PRIN2%),%CUR_PRIN2,{note})}
I am struggling with a text expression for the sentence of Marriage facts.
I have recorded some marriages with only one principal, sometime the Groom or Bride depending on the information that I have. In these cases I am very uncertain of the other persons name and record the possibilities in the notes field rather than creating another individual.
I would like to construct a summary template sentence which supports these two scenarios where the groom is the principal:
Marriage-1 with two individuals: Groom, Bride & Notes - sentence "Marriage: Groom-Name & Bride-Name ; Notes"
Marriage-2 with only principal1: Groom & Notes - sentence "Marriage: Groom-Name & Notes"
Sort of on the lines of:
"Principal1-name & <(principal2-name if there is a principal2 otherwise Notes)> <; (Notes if there is a principal-2)>"
The only conditional test I can find is using =TextIf() however this only appears to support static text in the last two expressions, I cannot find a way of entering =TextIf(no-exists...) and it will not support the following:
{=TextIf(exists(%CUR_PRIN2%),%CUR_PRIN2,{note})}
- tatewise
- Megastar
- Posts: 27088
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Help with text expression
I think you are over-complicating things. Have you tried something like:
Marriage: {%CUR_PRIN%} & <{%CUR_PRIN2%}; >{note}
where the < chevrons > conditionally include the Bride's name.
The simplification is recognising that {%CUR_PRIN%} , the ampersand & , and the {note} are unconditional.
So only the {%CUR_PRIN2%} existence matters.
BTW: The =TextIf(...) function would work but there are some tricks needed as shown below.
{=TextIf( Exists(%CUR_PRIN2%), %CUR_PRIN2%, %FACT.NOTE2% )}
%CUR_PRIN2% works Ok as text but your posted example had the trailing % missing so it would not work.
You cannot use codes such as {note} inside functions and must substitute the Data Ref such as %FACT.NOTE2%.
BTW: Parameters can be forced to use text format or various components combined by using the =Text(...) function.
Marriage: {%CUR_PRIN%} & <{%CUR_PRIN2%}; >{note}
where the < chevrons > conditionally include the Bride's name.
The simplification is recognising that {%CUR_PRIN%} , the ampersand & , and the {note} are unconditional.
So only the {%CUR_PRIN2%} existence matters.
BTW: The =TextIf(...) function would work but there are some tricks needed as shown below.
{=TextIf( Exists(%CUR_PRIN2%), %CUR_PRIN2%, %FACT.NOTE2% )}
%CUR_PRIN2% works Ok as text but your posted example had the trailing % missing so it would not work.
You cannot use codes such as {note} inside functions and must substitute the Data Ref such as %FACT.NOTE2%.
BTW: Parameters can be forced to use text format or various components combined by using the =Text(...) function.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- LornaCraig
- Megastar
- Posts: 2996
- Joined: 11 Jan 2005 17:36
- Family Historian: V7
- Location: Oxfordshire, UK
Re: Help with text expression
It's possible to simplify the template even more. By default narrative reports in FH will include the fact note immeditely after the sentence (but FH is clever enough not to repeat the note if it has already been inlcuded in the sentence template.) So if you are happy for all fact notes to be included automatically in reports you don't need to include {note} in the sentence template at all.
If you don't want all fact notes to appear in narrative reports you can untick the option to Inc Event/Attr Notes in the main tab of the Report Options. In that case the {note} will need to be included in the template for the marriage sentence.
If you don't want all fact notes to appear in narrative reports you can untick the option to Inc Event/Attr Notes in the main tab of the Report Options. In that case the {note} will need to be included in the template for the marriage sentence.
Lorna
- tatewise
- Megastar
- Posts: 27088
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Help with text expression
In most instances that would work, but in this case, he records the possibilities in the notes field and they need to immediately follow the ampersand & without an intervening full stop, which gets inserted when the Report Option to Inc Event/Attr Notes is enabled.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- phillip_leslie
- Gold
- Posts: 21
- Joined: 30 Jun 2022 07:49
- Family Historian: V7
- Location: Huddersfield, West Yorkshire, UK
Re: Help with text expression
Thank you everyone for the responses. Mike's suggestion of using:
{=TextIf( Exists(%CUR_PRIN2%), %CUR_PRIN2%, %FACT.NOTE2% )}
works for what I need, the bit I was missing was the %FACT.NOTE2%, as I was trying to use just {note} and that caused the condition to fail.
I am having to learn a lot since transitioning from TMG a few weeks ago. The one thing I am just beginning to realise after 20 years of TMG is that for all of that time I had no access to any technical support group with the quality of experience and the willingness to help others, such as yourselves. Therefore I made some wrong decisions on how to record and report on my data. I am now trying to reverse engineer those mistakes as I learn the capabilities of FH.
{=TextIf( Exists(%CUR_PRIN2%), %CUR_PRIN2%, %FACT.NOTE2% )}
works for what I need, the bit I was missing was the %FACT.NOTE2%, as I was trying to use just {note} and that caused the condition to fail.
I am having to learn a lot since transitioning from TMG a few weeks ago. The one thing I am just beginning to realise after 20 years of TMG is that for all of that time I had no access to any technical support group with the quality of experience and the willingness to help others, such as yourselves. Therefore I made some wrong decisions on how to record and report on my data. I am now trying to reverse engineer those mistakes as I learn the capabilities of FH.
- tatewise
- Megastar
- Posts: 27088
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Help with text expression
Why is my first suggestion not suitable?
Marriage: {%CUR_PRIN%} & <{%CUR_PRIN2%}; >{note}
That should match the two scenarios you quoted where the Note text is unconditionally always the last item.
The alternative is far more complex that necessary and has snags.
Marriage: {%CUR_PRIN%} & {=TextIf( Exists(%CUR_PRIN2%), %CUR_PRIN2%, %FACT.NOTE2% )}
The Note text is omitted when the Bride %CUR_PRIN2% exists, so does not match your scenarios.
There is a slightly less complex alternative but it suffers the same snags:
Marriage: {%CUR_PRIN%} & {=CombineText( "", %CUR_PRIN2%, "", %FACT.NOTE2% )}
There is a further snag associated with the discussion of the Inc Event/Attr Notes option.
That option recognises the {note} code and avoids including the same Note text twice.
However, it doe NOT recognise the equivalent %FACT.NOTE2% data reference.
So if both the option is enabled and the data reference exists then the Note text is displayed twice.
Marriage: {%CUR_PRIN%} & <{%CUR_PRIN2%}; >{note}
That should match the two scenarios you quoted where the Note text is unconditionally always the last item.
The alternative is far more complex that necessary and has snags.
Marriage: {%CUR_PRIN%} & {=TextIf( Exists(%CUR_PRIN2%), %CUR_PRIN2%, %FACT.NOTE2% )}
The Note text is omitted when the Bride %CUR_PRIN2% exists, so does not match your scenarios.
There is a slightly less complex alternative but it suffers the same snags:
Marriage: {%CUR_PRIN%} & {=CombineText( "", %CUR_PRIN2%, "", %FACT.NOTE2% )}
There is a further snag associated with the discussion of the Inc Event/Attr Notes option.
That option recognises the {note} code and avoids including the same Note text twice.
However, it doe NOT recognise the equivalent %FACT.NOTE2% data reference.
So if both the option is enabled and the data reference exists then the Note text is displayed twice.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- phillip_leslie
- Gold
- Posts: 21
- Joined: 30 Jun 2022 07:49
- Family Historian: V7
- Location: Huddersfield, West Yorkshire, UK
Re: Help with text expression
Hi Mike, You are correct, the first suggestion is the better one and works perfectly, I have now adopted that as my version.
One last question if I may, on similar lines with =TextIf, my last one for a few weeks before I go on holiday.
I have some census records (Fact Type Event, Record Type Individual) which contain a name in the Address field (please don't ask why, its one of my last legacy data issues from TMG).
I have tried to construct a witness sentence along the lines of the following to use address rather than the principals name if address is not empty:
{individual} was listed as a 'Boarder' of {=TextIf(ContainsText({address},"*"),{address},{principal})} in the census {date} {place}; {note}
However the TextIf with either ContainsText({address},"*") does not work and I have also tried TextLen({address})<>0
Do you have any suggestions?
One last question if I may, on similar lines with =TextIf, my last one for a few weeks before I go on holiday.
I have some census records (Fact Type Event, Record Type Individual) which contain a name in the Address field (please don't ask why, its one of my last legacy data issues from TMG).
I have tried to construct a witness sentence along the lines of the following to use address rather than the principals name if address is not empty:
{individual} was listed as a 'Boarder' of {=TextIf(ContainsText({address},"*"),{address},{principal})} in the census {date} {place}; {note}
However the TextIf with either ContainsText({address},"*") does not work and I have also tried TextLen({address})<>0
Do you have any suggestions?
- tatewise
- Megastar
- Posts: 27088
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Help with text expression
Remember what I said earlier:
"You cannot use codes such as {note} inside functions and must substitute the Data Ref such as %FACT.NOTE2%.
The same applies to code {address} whose Data Ref is %FACT.ADDR%.
Ditto for code {principal} whose Data Ref is %CUR_PRIN% as we used earlier.
However, in my opinion, retaining Names in the Address field is storing up problems.
For example, in the other types of Report and maybe in Diagrams those Address values will look very odd.
I suggest they should be moved to a labelled Note as illustrated in the FHUG Knowledge Base advice
Narrative Report Fact Sentence Templates under Custom Fact Fields.
If you have a lot of such Names that need moving then a Plugin would automate the process.
"You cannot use codes such as {note} inside functions and must substitute the Data Ref such as %FACT.NOTE2%.
The same applies to code {address} whose Data Ref is %FACT.ADDR%.
Ditto for code {principal} whose Data Ref is %CUR_PRIN% as we used earlier.
However, in my opinion, retaining Names in the Address field is storing up problems.
For example, in the other types of Report and maybe in Diagrams those Address values will look very odd.
I suggest they should be moved to a labelled Note as illustrated in the FHUG Knowledge Base advice
Narrative Report Fact Sentence Templates under Custom Fact Fields.
If you have a lot of such Names that need moving then a Plugin would automate the process.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- phillip_leslie
- Gold
- Posts: 21
- Joined: 30 Jun 2022 07:49
- Family Historian: V7
- Location: Huddersfield, West Yorkshire, UK
Re: Help with text expression
Thanks Mike. I have now fully understand the need to use Data References inside functions. I'll investigate the custom fact fields to mitigate my problem. Many thanks again. Phillip