* Given Name Case Convert

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
stewartrb
Diamond
Posts: 79
Joined: 21 Jun 2012 16:12
Family Historian: V7
Location: Chesapeake, VA

Given Name Case Convert

Post by stewartrb » 20 May 2016 22:52

I have the Surname Case Convert plugin and it works great.

Except the family member who used all capitals for her surnames also used all capitals for the given names.

I suspect it might all comes down to this line:

strSurname = string.match(fhGetValueAsText(pName),"%b//")

I'm guessing the // is the Surname container? Not sure what the %b is doing.

So rather than converting the surname, I'd like to convert the given name.

I'm not really finding clues how to get the given name/s instead of the surname/s.

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

Re: Given Name Case Convert

Post by tatewise » 21 May 2016 11:00

The "%b//" is an Lua Pattern as explained in plugins:understanding_lua_patterns|> Understanding Lua Patterns.
It is designed to recognise bracket pairs such as (...) or in this case /.../

Three lines in the Plugin need changing, and you have already found the first one.

Line 47 must match all leading characters except / to extract all forenames:
strSurname = string.match(fhGetValueAsText(pName),"%b//")
strSurname = string.match(fhGetValueAsText(pName),"^[^/]+")

Line 92 must not enclose name in /.../ pair:
tblSurname2['/'..line:upper()..'/'] = '/'..line..'/'
tblSurname2[line:upper()] = line

Line 102 is similar to line 47:
strName = string.gsub(oldname,"%b//",tblSurname2)
strName = string.gsub(oldname,"^[^/]+",tblSurname2)

Also every occurrence of Surname should be replaced by Forename throughout.

It may need further development to cater for Unicode UTF-8 accented letters.
In fact it needs a major overhaul, because instead of using those string.gsub() functions it can use NAME:SURNAME and NAME:GIVEN_ALL qualifiers, and a number of other features introduced since 2013.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
stewartrb
Diamond
Posts: 79
Joined: 21 Jun 2012 16:12
Family Historian: V7
Location: Chesapeake, VA

Re: Given Name Case Convert

Post by stewartrb » 21 May 2016 12:48

Thank you.

As I was researching some of the "language" on the internet, for things like fhGetValueAsText. It instead found GetValueAsText in the Unreal Engine documentation, a video game. Which apparently uses LUA like FH does.

I will look into the LUA Patterns page. (I programmed in Basic, Pascal, Fortran, and COBOL in college and my early days.)

The tweaks worked like a charm.

Again, thank you. (And thanks to Jane/Calico Pie for the helpful plugin in the first place.)
Last edited by stewartrb on 21 May 2016 13:14, edited 1 time in total.

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

Re: Given Name Case Convert

Post by tatewise » 21 May 2016 13:02

Yes Stewart, Lua is widely used, especially in the gaming community.

The Understanding Lua Patterns article is just one of several in plugins:index|> Family Historian Plugins under the Developer Guide that I strongly advise you study in depth.

The FH Tools > Plugins window also has extensive help under How to Write Plugins including all the API Functions such as fhGetValueAsText() and much more...
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply