Page 1 of 1
Given Name Case Convert
Posted: 20 May 2016 22:52
by stewartrb
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.
Re: Given Name Case Convert
Posted: 21 May 2016 11:00
by tatewise
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.
Re: Given Name Case Convert
Posted: 21 May 2016 12:48
by stewartrb
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.)
Re: Given Name Case Convert
Posted: 21 May 2016 13:02
by tatewise
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...