* Create a Text Scheme to show Nickname

Questions about creating, customising and using diagrams and charts
Post Reply
avatar
JohnB47
Gold
Posts: 10
Joined: 31 May 2024 19:42
Family Historian: V7

Create a Text Scheme to show Nickname

Post by JohnB47 »

OK, I'm going to dive in here. Having seen some older posts around the area, I think it's going to be interesting, or perhaps challenging?

I can see how you can have a Text Scheme where the AKA name can be added to Diagrams, Charts and Reports. I've played with that and it works fine.

However, what I would really like is the following. I would like every instance of a persons name, apart from the focus window (where their name and AKA name and Nickname would always be in separate fields) to show their full name and with the Nickname, in brackets, immediately after their first name. The AKA field would not be used.

So, for example, a person called Joseph William Bloggs, whose Nickname is Joe, would appear as Joseph (Joe) William Bloggs. I might later decide to change that to Joseph "Joe" William Bloggs if I can understand how to manipulate the code required.

Can anyone point me to where this could be explained? I've found the help info. about creating Text Schemes but it doesn't show how to actually create code, rather than making a choice of code lines already written. In the Knowledge Base, I've found that using %INDI.NAME:SURNAME% outputs a surname but how do you output a first name, or a Nickname? And how do you chain them together and enter characters like ( or ) to produce an output like Joseph (Joe) William Bloggs.

I really am happy to figure this out myself, I just need some examples and guidance to set me up.

Edit: I've just found Mikes reply to my earlier thread about this, where he said:

"In FH many features support expressions which allow Data References to identify specific fields.
The Data Reference for the Nickname field is %INDI.NAME.NICK%
That cannot be added to the Focus Window, but it is possible to customise Charts, Reports, and other displays to include Nicknames by using that Data Reference. We can discuss the details later, which depend on exactly how you wish the Nickname to be incorporated into the rest of the Name."

Thanks.
User avatar
tatewise
Megastar
Posts: 28594
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Create a Text Scheme to show Nickname

Post by tatewise »

OK, this is quite an advanced topic for a relative newcomer but here goes...

To compose complex displays like that involves a combination of Data References and Functions in an Expression.
Most Expressions offer a Data Ref Assistant to help compose Data Refs but you are on your own with Functions.
See the FH Help > General Topics > Name Formats for details of field qualifiers such as SURNAME.

To concatenate text fields together employs the =Text(...) function, e.g.
=Text( %INDI.NAME:FIRST% . " " . %INDI.NAME:SURNAME% ) to produce Joseph BLOGGS.

To conditionally enclose a Nickname in parentheses use the =CombineText(...) function, e.g.
=CombineText( " (", %INDI.NAME.NICK%, ") ", " " ) to produce (Joe) but only if Joe exists.
If Joe does not exist it produces a single space character.

So putting those two together we get:
=Text( %INDI.NAME:FIRST% . CombineText( " (", %INDI.NAME.NICK%, ") ", " " ) . %INDI.NAME:SURNAME% ) to produce Joseph (Joe) BLOGGS.

I'll leave it up to you to work out how to conditionally include any middle names such as William with spacing.

See FHUG Knowledge Base > Understanding Expressions which links to Understanding Data Refs and Functions.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
JohnB47
Gold
Posts: 10
Joined: 31 May 2024 19:42
Family Historian: V7

Re: Create a Text Scheme to show Nickname

Post by JohnB47 »

Thanks for the leg up.

I've got this working now, although my method might not be orthodox. And certain spacing is a niggle though.

Here's what I did. I opened a Descendants Diagram and right clicked on a space to open the Diagram Options dialog, then selected the Text tab. The scheme selected was Birth, Marr, Death. I clicked on Edit Text Scheme, then in the right hand window under Items Used, I clicked on Name, then Edit. I replaced the Template entry with a modification of your suggestion:

=Text(%INDI.NAME:FIRST% . CombineText(" (",%INDI.NAME.NICK%,") "," ") . %INDI.NAME:MIDDLE% . " " . %INDI.NAME:SURNAME%)

I then used Test, then Apply.

This produced the layout: Joseph (Joe) William Bloggs in the diagram. All nicely spaced out. I then played about and got [ ] around the nickname and * * too. However the code didn't like it when I tried to change it to produce Joseph "Joe" William Bloggs. Is that possible somehow?

Then I saw that, where no middle name was present, there was always a double space just before the surname. Everything was nicely spaced only if there was a middle name, irrespective of a nickname being present or not. I couldn't manage to change that without upsetting other spacing. Is that fixable or do I have to live with that?

Also, I know that I should now go back in and undo my changes and create a new Text Scheme by adding the modification to a cloned version of the Birth, Marr, Death one, then use that as my default scheme. That would be the correct way to do it.

Thanks for the help with this.
User avatar
tatewise
Megastar
Posts: 28594
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Create a Text Scheme to show Nickname

Post by tatewise »

Excellent. Using the Clone option and keeping the installed Text Scheme unchanged is what I recommend.

It is not possible to include simple double quotes in a string but there are workarounds.
1) Use two single quotes instead, e.g. " '' "
2) Use opening and closing double quotes, e.g. " “ " and " ” " obtained from Windows Character Map

The clue I gave was to conditionally include any middle names such as William with spacing.
i.e. Similar to the conditional nickname, e.g.
=CombineText( "", %INDI.NAME:MIDDLE%, " ", "" ) which produces William and space or nothing.

So the Template expression to enclose the Nickname in opening & closing double quotes is:
=Text( %INDI.NAME:FIRST% . CombineText( " “", %INDI.NAME.NICK%, "” ", " " ) . CombineText( "", %INDI.NAME:MIDDLE%, " ", "" ) . %INDI.NAME:SURNAME% )
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
JohnB47
Gold
Posts: 10
Joined: 31 May 2024 19:42
Family Historian: V7

Re: Create a Text Scheme to show Nickname

Post by JohnB47 »

Thank you. I'll have to leave it til tomorrow to try that out but it looks good.
avatar
JohnB47
Gold
Posts: 10
Joined: 31 May 2024 19:42
Family Historian: V7

Re: Create a Text Scheme to show Nickname

Post by JohnB47 »

Thanks for that last item of code Mike. I now have exactly what I want.

I did miss the hint that I should use CombineText for the middle name too, to avoid unwanted spaces.

I've created a new Text Scheme called Birth, Marr, Death, Nickname (custom) and it displays the names and nicknames exactly how I want and with perfect spacing.

I'm surprised this isn't one of the supplied Schemes - it seems to me a natural way to display nicknames in a Diagram/Chart etc.

Thanks for the great help with this - a very enjoyable exercise.
Post Reply