* How to locate missing census facts in a plugin
How to locate missing census facts in a plugin
I am new to plugin coding, but progressing well, and have been able to go through the records, and Identify each individual who was alive at each census.
I now need to check if they already have a census fact for a specific year.
This is achieved this in a query by including the row item, Exclude if =Exists(%INDI.CENS[year=1841]%)
How do I reproduce this in a plugin?
With possibly none or more census facts for each individual, how do I check if one of them is for 1841?
I now need to check if they already have a census fact for a specific year.
This is achieved this in a query by including the row item, Exclude if =Exists(%INDI.CENS[year=1841]%)
How do I reproduce this in a plugin?
With possibly none or more census facts for each individual, how do I check if one of them is for 1841?
Mike Loney
Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com
Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com
- tatewise
- Megastar
- Posts: 27082
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: How to locate missing census facts in a plugin
I presume you have been able to retrieve ~.BIRT and ~.DEAT facts for each INDI.
So use similar technique to retrieve ~.CENS[year=1841] and if the returned pointer is Null then no Census Event exists for 1841, and this is an INDI whose To Do Fact needs updating.
So use similar technique to retrieve ~.CENS[year=1841] and if the returned pointer is Null then no Census Event exists for 1841, and this is an INDI whose To Do Fact needs updating.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: How to locate missing census facts in a plugin
Mike,
Thanks for that, I must have been doing something wrong, as I didn't realise the phrase [year=1841] was still a valid expression, as it didn't seem to work!
I'll give it another try!
Thanks for that, I must have been doing something wrong, as I didn't realise the phrase [year=1841] was still a valid expression, as it didn't seem to work!
I'll give it another try!
Mike Loney
Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com
Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com
- tatewise
- Megastar
- Posts: 27082
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: How to locate missing census facts in a plugin
Assuming you have ptrIndi pointing to Individual record then the following works:
You can even set a variable for the year itself and obtain that from the user:
Code: Select all
local ptrCens = fhGetItemPtr(ptrIndi,"~.CENS[year=1841]")
if ptrCens:IsNull() then
end
Code: Select all
local strYear = "1841"
local ptrCens = fhGetItemPtr(ptrIndi,"~.CENS[year="..strYear.."]")
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: How to locate missing census facts in a plugin
Mike,
Once again many thanks.
I do feel the documentation on plugins is somewhat lacking.
for example why the '..' in the expression [census=..stryear..]?
Haven't come across these in the documentation, except for string concatenation!
Once again many thanks.
I do feel the documentation on plugins is somewhat lacking.
for example why the '..' in the expression [census=..stryear..]?
Haven't come across these in the documentation, except for string concatenation!
Mike Loney
Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com
Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com
- tatewise
- Megastar
- Posts: 27082
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: How to locate missing census facts in a plugin
Well, you are correct, it is string concatenation!
"~.CENS[year=" plus strYear plus "]" becomes "~.CENS[year=1841]" if strYear contains "1841" i.e. two literal strings and a string variable concatenated together.
You need to supplement the specific FH API documentation with the general Lua documention especially http://www.lua.org/manual/5.1/ mentioned in several places. Much of the code in a Plugin is general Lua so only the FH API is provided by FH help pages.
In plugins:getting_started|> Getting Started Writing Plugins the very first sentence says "Plugins are written in Lua (currently release 5.1)," and that blue link takes you to the manual.
It is also in the FH help page Introduction to Lua near the bottom, and in the Plugin editor window it is under Help > Lua Online Reference Manual.
"~.CENS[year=" plus strYear plus "]" becomes "~.CENS[year=1841]" if strYear contains "1841" i.e. two literal strings and a string variable concatenated together.
You need to supplement the specific FH API documentation with the general Lua documention especially http://www.lua.org/manual/5.1/ mentioned in several places. Much of the code in a Plugin is general Lua so only the FH API is provided by FH help pages.
In plugins:getting_started|> Getting Started Writing Plugins the very first sentence says "Plugins are written in Lua (currently release 5.1)," and that blue link takes you to the manual.
It is also in the FH help page Introduction to Lua near the bottom, and in the Plugin editor window it is under Help > Lua Online Reference Manual.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: How to locate missing census facts in a plugin
Reminds me of programming msAccess, with SQL statements, putting variables inside quotes using concatenation just like LUA
Only trouble is, it doesn't makes reading code easy, nor debugging!
Only trouble is, it doesn't makes reading code easy, nor debugging!
Mike Loney
Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com
Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com
- tatewise
- Megastar
- Posts: 27082
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: How to locate missing census facts in a plugin
I suspect you have misunderstood string concatenation, because variables will never be inside quotes, otherwise they are no longer variables.
Take "~.CENS[year=" .. strYear .. "]" for example.
"~.CENS[year=" is one quoted literal string
strYear is a variable (not inside quotes) and may be assigned any literal string
"]" is another quoted literal string
c.f.
"strYear" is a quoted literal string, not a variable
All three are joined together to form one long string.
Think of the .. operator for strings as similar to the + operator for numbers.
Take "~.CENS[year=" .. strYear .. "]" for example.
"~.CENS[year=" is one quoted literal string
strYear is a variable (not inside quotes) and may be assigned any literal string
"]" is another quoted literal string
c.f.
"strYear" is a quoted literal string, not a variable
All three are joined together to form one long string.
Think of the .. operator for strings as similar to the + operator for numbers.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Re: How to locate missing census facts in a plugin
Mike,
Not the case at all, it is just a case of being unfamilar with LUA, not recognising what is inside quotes and what is outside. As I already said, doesn't make for easy reading of code.
Not the case at all, it is just a case of being unfamilar with LUA, not recognising what is inside quotes and what is outside. As I already said, doesn't make for easy reading of code.
Mike Loney
Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com
Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com