* Given Name Used (_USED) not behaving as expected

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
User avatar
Talln
Gold
Posts: 18
Joined: 09 Feb 2021 17:15
Family Historian: V7
Location: London

Given Name Used (_USED) not behaving as expected

Post by Talln »

Hi all

There's probably a good reason, but I'm not getting any "given named used" when using a plugin to extract names. Code snippet:

Code: Select all

 
ptrName = fhNewItemPtr()
ptrName:MoveTo(ptrIndi,"~.NAME")
local givennameused = fhGetItemText(ptrName,'~:_USED')
fhMessageBox('givennameused:='..givennameused)
Test data in FH:
Name: "Mary Test Jones"
Name used: "Test"

But the value of givennameused is always "". This only appears to be a problem for _USED as the same code works for SURNAME, NICK, NSFX values.

In a Query, %INDI.NAME[1]._USED% works fine.

I wanted to add underlines using:

Code: Select all

presentationname = presentationname:gsub(givennameused,"<ul>"..givennameused.."</ul>")
So before I spend all morning inside, missing the wonderful sun, I thought I'd ask for help!!

Thanks in anticipation
Paul
Paul Weaver, London
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Given Name Used (_USED) not behaving as expected

Post by tatewise »

Hi Paul.

You are mixing up Name Qualifiers and Name subfields.

As you say, %INDI.NAME[1]._USED% works in a Query so that will work in a Plugin. See the dot (.) instead of colon (:).
i.e.
ptrIndi,"~.NAME" effectively gives data ref INDI.NAME
ptrName,"~._USED" effectively gives data ref INDI.NAME._USED

In your Query, use the Columns tab, Fields pane, to determine data references.
Click the down-arrow droplist under the box below that pane and choose Show Both in Box.
Click the [+] next to Name to reveal all the options.
Select each option in turn to see the data reference in the box below.

The options starting with a colon (:) and in capitals are Name Qualifiers with a colon separator.
e.g. %INDI.NAME:SURNAME%
Of the ones you mentioned, this is the only one that needs the colon separator required for Qualifiers.
The other Qualifiers manipulate the NAME components to display them in various ways.

The options in the bullet list below are Name subfields with a dot separator.
e.g. %INDI.NAME.NICK% and %INDI.NAME.NSFX% and %INDI.NAME._USED%
So contrary to what you said, these all use the dot separator as they are all subfields.
These subfields exist in their own right and can each hold any text.

Just to confuse things there is both a :SURNAME Qualifier and a Surname subfield:
%INDI.NAME:SURNAME% extracts the name between / and / in the NAME field.
%INDI.NAME.SURN% is a NAME subfield that is rarely used in FH but exists in the GEDCOM spec.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Talln
Gold
Posts: 18
Joined: 09 Feb 2021 17:15
Family Historian: V7
Location: London

Re: Given Name Used (_USED) not behaving as expected

Post by Talln »

Thanks for the explanation Mike.

I have seen the other fields working, but I recently re-wrote the code and I guess I used the surname code as a template, not noticing the subtle difference!

Cheers!
Paul Weaver, London
Post Reply