for instance:
gen 0: I have me, no birth date
gen1: my father no birth date
gen2: my grand father born 1887
ok, so one can see for estimation I need a multiplier (generation!)
simply illustrated:
assume a man is a father on average at 25. assume it takes 1 year to have a baby.
(already wrong I know..but)
so 1887+ 25 * 2gen) + 2gen years babymaking results in births:
gen 2: gf 1887
gen 1: f 1913
gen 0: me 1939
actual are
2.gf 1887
1.f 1918 (2nd son so add 1 there and 1914, but we aint there yet)
0.me 1954 so 15 years lite, but my father was married late (after the war, and my mothers 2nd marriage so that has to factor in, she was born 1922 but let us leave the complexities for a moment)
where can I get dates to help with estimation, wife born, marr, ancestor births, marr, and so on, children born...
so I found a fairly light frame for ancestors and descendants when I went shopping in the code snippets.
it is fundamentally the exact program in snippets decorated, and while it was easy to decide where the generations were on ancestors, on descendants not so easy.
to demonstrate:
geo and ruth ( my ggf 1869 my ggm 1871)
geo jr 1890
flossy 1897 not handy
beatrice 1902
lester 1907
leslie 1907
their children
geo jr 0
flossy 4
beatrice 1
lester and leslie (twins) 0
it is trivial to get the generation in ascendency **and know it before I make the table entry** which generation I am on (my multiplier) when hunting for dates.
at some point, I would expect the not so random dates I collect to coalesce in a reasonable time frame. I will have to do a sideways (his wife ) and a 1 up, his brothers and sisters, but otherwise it is parents by generation, and downwards by generation and work back with negatives that is
born 1954 - 2 gen * 25 = 1900 (for my 1887 grandfather. again, much more complex calcs than are explained here, but I have around 60% of my file with no birth and or death, and would like to estimate it better.
anyway, can someone figure out a clever way to straightforwardly count generations without going to gen=fhCallBuiltinFunction("RelationCode") every time?
Code: Select all
--[[
@function: IsInList
@description: Adds rcdid as value and index to table if it does not already exist
@parameters: Item Pointer - Must be at Record Level
@returns: true if pointer is a duplicate
@requires: none
]]
function IsInList(table, iptr)
local rcdid = fhGetRecordId(iptr)
if table[rcdid] == nil then
table[rcdid] = rcdid
return false
else
return true
end
end --fn IsInList
--[[
@function: rtvAncestors
@description: Returns a list of Ancestors
@parameters: Item Pointer - Must be at Record Level
@returns: table of record Item Pointers
@requires: IsInList
]]
function rtvAncestors(iptr)
local ancestors = {}
local inlist = {}
local ent = 0
local gen = 0
local ptrBAS = fhNewItemPtr()
local ptrFAMC = fhNewItemPtr()
local ptrHUSB = fhNewItemPtr()
local ptrWIFE = fhNewItemPtr()
table.insert(ancestors, iptr:Clone())
IsInList(inlist, iptr)
ent = 1
while ent <= #ancestors do
ptrBAS = ancestors[ent]
-- Loop Family as Child
ptrFAMC:MoveTo(ptrBAS,'~.FAMC')
while ptrFAMC:IsNotNull() do
gen = gen + 1
ptrHUSB:MoveTo(fhGetValueAsLink(ptrFAMC), '~.HUSB>')
if ptrHUSB:IsNotNull()
and (not IsInList(inlist, ptrHUSB)) then
table.insert(ancestors, ptrHUSB:Clone())
end
ptrWIFE:MoveTo(fhGetValueAsLink(ptrFAMC), '~.WIFE>')
if ptrWIFE:IsNotNull()
and (not IsInList(inlist, ptrWIFE)) then
table.insert(ancestors, ptrWIFE:Clone())
end
ptrFAMC:MoveNext('SAME_TAG')
end
ent = ent + 1
end
return ancestors
end --fn rtvAncestors
--[[
@function: rtvDescendants
@description: Returns a list of decendants
@parameters: Item Pointer - Must be at Record Level
@returns: table of record Item Pointers
@requires: IsInList
]]
function rtvDescendants(iptr)
local decendants = {}
local inlist = {}
local ent = 0
local gen = 0
local ptrBAS = fhNewItemPtr()
local cptrFAMS = fhNewItemPtr()
local ptrFAMS = fhNewItemPtr()
local cptrCHIL = fhNewItemPtr()
local ptrCHIL = fhNewItemPtr()
table.insert(decendants, iptr:Clone())
IsInList(inlist, iptr)
ent = 1
while ent <= #decendants do
ptrBAS = decendants[ent]
-- Loop Family as Spouse
cptrFAMS:MoveTo(ptrBAS, '~.FAMS')
while cptrFAMS:IsNotNull() do
ptrFAMS = fhGetValueAsLink(cptrFAMS)
-- Loop Children
cptrCHIL:MoveTo(ptrFAMS, '~.CHIL')
while cptrCHIL:IsNotNull() do
ptrCHIL = fhGetValueAsLink(cptrCHIL)
if ptrCHIL:IsNotNull()
and not IsInList(inlist, ptrCHIL) then
table.insert(decendants, ptrCHIL:Clone())
end
cptrCHIL:MoveNext('SAME_TAG')
end
cptrFAMS:MoveNext('SAME_TAG')
end
ent = ent + 1
end
return decendants
end --fn GetDecendantList
-- USAGE:
tblROOT = fhPromptUserForRecordSel('INDI', 1)
if #tblROOT == 0 then
return
-- table.insert(decendants, fhGetValueAsLink(cptrCHIL))
end
local ptrINDI = tblROOT[1]
local tblAncs = rtvAncestors(ptrINDI)
local tblDesc = rtvDescendants(ptrINDI)
return