Page 1 of 1

Unmarried mothers & loop indices

Posted: 06 Dec 2022 12:00
by Glenn Webby
Hi folks,

In my diagrams I use %INDI.FAMS[1+]>HUSB.NAME:SURNAME% to navigate and find the married name for women in my tree. Of course given the underlying data model, this comes unstuck when a woman doesn't actually marry a man she had some form of relationship with. I see that the attribute family 'Status' could be Divorced, Separated, Unmarried Couple, Never Married, Unknown or <default>. In the cases of 'Never Married' and 'Unmarried Couple' I would like to not output the male partner's surname. So I'd like to do a test on the Text Scheme for Married Name along the lines of:

IF (%FAM._STAT% == "Never Married" OR %FAM._STAT% == "Unmarried Couple") THEN
ELSE
%INDI.FAMS>HUSB.NAME:SURNAME%

I've tried several text functions in the text scheme line such as TextIf, ContainsText, NotExistsText but the problem is probably my misunderstanding of looping indices. I've read the FH Help and gone round in circles -- excuse the pun. The reason I need looping indices is because of the situation of multiple marriages.

So at present my code reads:
=TextIf(Exists(%INDI.FAMS[1+]>_STAT%,,%INDI.FAMS>HUSB>NAME:SURNAME%)
[which I know only works if Unmarried Couple or Never Married is used versus <default> but that's ok]. My assumption in the code is the leading expression dictates the index of the group. I've tried 1+ in both FAMS instances but that appears to be incorrect too.

Could someone help me better understand loop indices when used in a multi part expression such that I loop through every family instance for the individual and check if they were an Unmarried Couple or Never Married before printing the husband's surname?

Many thanks in advance.

Re: Unmarried mothers & loop indices

Posted: 06 Dec 2022 13:15
by tatewise
Based closely on your example the following works for me:
=TextIf( Exists( %INDI.FAMS[1+]>_STAT% ), , %INDI.FAMS[1+]>HUSB>NAME:SURNAME% )

The key points are:
1) Every occurrence of FAMS must use the looping index [1+]
2) Check that each opening ( parenthesis has a matching closing parenthesis )
In your example the Exists(...) function had no closing )

You can extend that expression to test ( %INDI.FAMS[1+]>_STAT% == "Never Married" ) etc.

Re: Unmarried mothers & loop indices

Posted: 06 Dec 2022 13:34
by Glenn Webby
Perfect Mike, thanks. I see I left off the closing ) for Exists -- been staring at it for hours and couldn't see simple the mistake. I'd like to claim old age but I'm not sure that's true. Useful to know that the looping index must be on each occurrence of FAMS too. Thanks again.

Re: Unmarried mothers & loop indices

Posted: 14 Dec 2022 16:48
by Glenn Webby
Hi Mike and/or anyone else,

I'm still having problems printing out married women's names in my diagrams. Based on the earlier help my latest line is:

=TextIf(IsTrue((Text(%INDI.FAMS[1+]>_STAT%) = "Never Married") or (Text(%INDI.FAMS[1+]>_STAT%) = "Unmarried Couple")),"",%INDI.FAMS[1+]>HUSB>NAME:SURNAME%)

The idea is that on the occurrence of a a couple that have "Never Married" or Unmarried Couple" status I don't print the male surname. On any other instance I do. This works fine IF ... the woman in question marries a man first and then has illegitimate children with another man afterwards. If the woman has illegitimate children first then marries, the married surname does not appear.

My representation of illegitimate children is for the mother to have a partnership with an "unnamed person" and the child to be the product. For me that seems like the best model, rather than just flagging the child is illegitimate. It definitively models the actual case which is that we don't know who the father is.

Just to add to the dilemma. If I print the married status as an independent phrase and follow that with the line above:
%INDI.FAMS[1+]>_STAT% =TextIf(IsTrue((Text(%INDI.FAMS[1+]>_STAT%) = "Never Married") or (Text(%INDI.FAMS[1+]>_STAT%) = "Unmarried Couple")),"",%INDI.FAMS[1+]>HUSB>NAME:SURNAME%)

... it works both with the illegitimate child before marriage as well as the illegitimate child after marriage. (Just to help, the scenario I'm thinking of and trying to model is the case when a woman has had illegitimate children before marrying another man versus a married woman who has had a child with man that isn't her husband.)

Any help greatly received.

Re: Unmarried mothers & loop indices

Posted: 14 Dec 2022 17:41
by tatewise
The problem that FH has is how to determine when the looping index has finished.
You might say it can look at %INDI.FAMS[n] and keep going as long as there is a Family as Spouse FAMS link instance.
However, it does not seem to do that but ends the looping when no text is returned.
So it is the empty " " returned when the Status is "Never Married" or "Unmarried Couple" that ends the looping.

Change that empty " " to "Unknown" or "<horizontal tab>" or "<no-break-space Unicode A0>" and the loop keeps going.

Re: Unmarried mothers & loop indices

Posted: 15 Dec 2022 11:02
by Glenn Webby
Thanks Mike, you seem to be 24/7 call out -- much appreciated.

My intention with the line:
=TextIf(IsTrue((%INDI.FAMS[1+]>_STAT% = "Never Married") or (%INDI.FAMS[1+]>_STAT%) = "Unmarried Couple"),"",%INDI.FAMS[1+]>HUSB>NAME:SURNAME%)

is that if the Status for a specific partnership is either "Never Married" or "Unmarried Couple" then to print "" on the diagram, and if it is neither to print the surname of the Husband. So it isn't or I didn't intend it to be searching for " ". But I think you mean that the FH algorithm loops until a null value is found rather than looping for every FAMS instance. So when _STAT is NULL, the loop ends? But when a woman is married multiple times the above line does loop for every instance of Husband.

Sorry I may have missed what you meant. Do you have a line that you would use to print a married surname for every instance of Husband that doesn't have the status of Unmarried Couple or Never Married (all other Marriage Status categories will change the woman's surname - arguably Unknown wouldn't but let's assume Unknown defaults to Married for simplicity).

Again, many thanks for your invaluable help.

Re: Unmarried mothers & loop indices

Posted: 15 Dec 2022 12:15
by tatewise
No, it is not _STAT being null that ends the loop. It is the empty string "" value returned by the Template that ends the loop.

If you change that empty string "" to anything that is not space characters then the loop continues.
e.g. Try substituting "unknown" and you will see what I mean:-
=TextIf(IsTrue((%INDI.FAMS[1+]>_STAT% = "Never Married") or (%INDI.FAMS[1+]>_STAT%) = "Unmarried Couple"),"unknown", %INDI.FAMS[1+]>HUSB>NAME:SURNAME%)

Instead of 'unknown', I've tried a horizontal tab character and a no-break space character.
They work but a blank line appears in the list.
I cannot think of any way to display absolutely nothing and still allow the loop to continue.

The only solution is to have a separate Template for each of %INDI.FAMS[1], %INDI.FAMS[2], %INDI.FAMS[3], on so on for as many multiple spouses as you need to cater for.

Re: Unmarried mothers & loop indices

Posted: 15 Dec 2022 12:30
by Glenn Webby
Mike,

do you think this is a possible bug with printing on a diagram?

If I take the Occupation Item from the Available Items list in the Diagram Options Text Scheme window and use the default:
=FactText(%INDI.OCCU[1+]%, "1SA","A_Occup: _ _ in _")

and use it on dummy FH family where someone has two occupation instances, one left blank, the other has an occupation only filled in.

If I put the blank occupation above the one that has an occupation filled in, change the line to read =FactText(%INDI.OCCU[1+]%, "1S","A_Occup: _ _ in _")

ie remove the qualifying A that ensures the precursor text "Occup:" is always printed regardless of whether there is an entry or not, then I find the order of the Occupation fact is important. If I put the blank one first no Occupation is printed out. If I put the filled one in first, then it gets printed out. It looks to be the same symptoms as my Married Name problem.

Re: Unmarried mothers & loop indices

Posted: 15 Dec 2022 12:31
by Glenn Webby
Sorry replied before you sent yours Mike. I think that confirms your point. This feels like a bug to me.

Re: Unmarried mothers & loop indices

Posted: 15 Dec 2022 12:32
by Glenn Webby
Yes, I think the multi line approach feels the easiest way forward.

Once again, I very much appreciate your help.

Re: Unmarried mothers & loop indices

Posted: 15 Dec 2022 12:54
by tatewise
I agree that the Occupation example ends the loop for the same reason of no text to display.
Whether it is a bug or by design is difficult to tell.
The Help says
A looping index has a ‘+’ after the index number, and means ‘repeat for all instances, starting with this one’. For example, an item with this text template:
%INDI.OCCU[1+]%
would show all occupations, starting with the first.
When there is no value for an occupation the looping stops and subsequent occupations are not shown.
So you could argue that the Help statement is not fulfilled because it does not show all occupations.

Try reporting it to CP and see what they say.

Re: Unmarried mothers & loop indices

Posted: 15 Dec 2022 12:59
by Glenn Webby
Yes,

and the same is true for the Marriage Item in the Text Scheme box. If the first instance of marriage has no text to display, the loop ends, so any subsequent marriage does not get reported.

I'll report to CP and revert.

Re: Unmarried mothers & loop indices

Posted: 15 Dec 2022 17:29
by Glenn Webby
Mike,
this from CP:
"Thank you for reporting that. We have replicated the problem using your examples - thank you. We have logged the issue and it will be passed to the developers for investigation. "

Re: Unmarried mothers & loop indices

Posted: 15 Dec 2022 17:48
by davidf
Glenn Webby wrote:
15 Dec 2022 17:29
We have replicated the problem using your examples - thank you
I've not seen that reported before; can we take that as an encouraging "higher level of acknowledgement"?

Re: Unmarried mothers & loop indices

Posted: 15 Dec 2022 21:11
by tatewise
Not necessarily as it is a normal response when they can reproduce unusual symptoms.

Re: Unmarried mothers & loop indices

Posted: 16 Dec 2022 22:29
by Glenn Webby
Further news ...

"This is just to let you know that the issue you raised will be fixed in the next update of Family Historian."

Good to know CP took it onboard and turned it around quickly.

Re: Unmarried mothers & loop indices

Posted: 17 Dec 2022 11:42
by tatewise
Excellent.