* what is all this then?

For plugin authors to discuss plugin programming
Post Reply
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

what is all this then?

Post by Ron Melby »

this is below lua 101 like 1st form lua, but I am not getting it.
code snip and some table entries

fID is the record id of a FAM record.


2. DEQ.fID 2217 is NEQ FAMLIMIT[DEQ.fID] 37


1 DEQ = QFAM:deQ()
2 if not FAMLIMIT[DEQ.fID] then
xptr:MoveToRecordById('FAM', DEQ.fID)
local ptrFAM = xptr:Clone()


-- pGEN = 86
-- cGEN = 86
hix = 0
3 local rcd = HHASH[DEQ.fID]
4 if rcd then
pGEN = rcd.pGEN
cGEN = rcd.cGEN
hix = rcd.hix
end

HHASH[DEQ.fID] does exist but
[2217] =
{
["POOL"] = 1,
["gix"] = 1,
["cGEN"] = -12,
["pGEN"] = -13,
["CHIL"] =
{
[1] = 5331,
},
["WIFE"] = "",
["fID"] = 2217,
["ix"] = 1,
["HUSB"] = 5332,
["PTG"] = 2,
},

4. rcd is nil

there is something so simple going on that I am not understanding. I have been messing with this for over 12 hours.
I need a fresh new eye to tell me where I wrote owt when I meant to write nowt in here.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28486
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: what is all this then?

Post by tatewise »

Sorry Ron, but I have no idea what you are talking about. Please explain the problem more precisely.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: what is all this then?

Post by Ron Melby »

after all day and almost all night yesterday of small changes here and there to debug and correct code and find this problem (likely compiled it several hundred times) I closed everything out and went to bed. I tried it this morning to try and better explain what is going on, no changes, it works. can constant and considerable debugging and compiling cause fh to be confused?
FH V.6.2.7 Win 10 64 bit
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Calculating a generational offset

Post by Ron Melby »

same program but slightly different topic.

I have a sister. her generational offset from me is 0, her husbands is also 0. fh calculates no generational offset to his parents, brothers, sisters, --- in short his kin. logically the generational offset between his parents and me is -1 we are all in pool 1. logically, everyone in pool one is some generation distant from me. I am the file root, and have calculated those offsets, by nefarious means in some cases that is; hand work and not programmatically.

Therefore:
I have a file (its that HHASH) which I can now keep up by hand and by program depending on relationships and generations to me.

I can find me as a generation, I am 0, and I can find the generation to anyone else in the file regardless of pool, lets ignore those not in pool 1.

I want to run this program with a different temporary root, everything will work correctly, relations and so on from this different root, what does not work is generational offset, so I get my generational offset = 0, then say I select a 4th cousin once removed, either 1 or -1 depending, am I correct that I add that generational offset to mine to use as an adjustment for generations with them as root?
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28486
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: what is all this then?

Post by tatewise »

Instead of calculating generation offsets by your own nefarious means try using the FH function:
=RelationCode( <Root Person>, %INDI%, GENERATION, 1 )
where <Root Person> is the temporary root.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: what is all this then?

Post by Ron Melby »

GEN = fhCallBuiltInFunction('RelationCode', QY_ROOT, iptr, 'Generation', ix or 1) -- or -100

go to your grandfather on your fathers side, pick a brother, then his son, that should put you and him at -1 if you are QY_ROOT and he is iptr, or vice versa. now go to his wife, which also should be generation -1 and go to her grandfather.

every bit of this is in pool one,

select her grandfather as QY_ROOT and you as iptr or vice versa, give me the number you get, please. Or explain if you will, what is wrong with my GEN statement,
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28486
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: what is all this then?

Post by tatewise »

To perform this analysis I have used the Family Historian Sample Project but have added G F CARRINGTON as the father of Alan CARRINGTON [58] who is the father of Charlotte CARRINGTON [25] wife of Ian Stephen MUNRO [6].

I have chosen the Root person as Graham Anthony MUNRO [66] whose grandfather is Peter Michael MUNRO [9] the brother of Anthony Edward MUNRO [1] whose son is Ian Stephen MUNRO [6].

The relationship between the Root person and his grandfather's brother's son is '1st cousin once-removed' with a Generation gap of -1.

The son's wife is '1st cousin once-removed's wife' with as you say the same Generation gap of -1.

But the Root has no direct relationship to her grandfather as confirmed by the Tools > How Related... command.
So the fhCallBuiltInFunction('RelationCode', ...) function returns nil.

image.png
image.png (138.11 KiB) Viewed 822 times

This is the plugin script I used to test the relationships.

Code: Select all

local ptrRoot = fhNewItemPtr()
local ptrIndi = fhNewItemPtr()
ptrRoot:MoveToRecordById("INDI",66) -- Graham Anthony MUNRO
for _, intRec in ipairs ({ 6; 25; 58; 123; }) do
	ptrIndi:MoveToRecordById("INDI",intRec)
	local GEN = fhCallBuiltInFunction( "RelationCode", ptrRoot, ptrIndi, "GENERATION", 1 )
	local REL = fhCallBuiltInFunction( "Relationship", ptrRoot, ptrIndi, "TEXT", 1 )
	print(GEN,REL)
end
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: what is all this then?

Post by Ron Melby »

Precisely my point at the outset Mike. I can by the nefarious means of inspection and counting by hand say: she is -1 therefore her father is -2 and her grandfather -3 from me, the root; at 0, and install that in a table, and by that same process, do all other non-relations in pool 1. The other pools can be fairly closely estimated by a survey of their peers. Say someone in my file in another pool is born in the 1820s, so I go thru my file of generations in the 1820s and find the bulk are -4 from me with some few odd ones at -5. I select -4 as the educated guess of the generation, I could be wrong, but not wildly wrong, they are not -11 generations nor -1 generations from me. I have perhaps 20 people total in other pools (and that is 3 other pools). They are in my file because I am investigating if we are genealogically 'related'. So, I have a generation for all 3855 families, and therefore for all 9557 individuals in my gedcom, based on me as root. As you might imagine now; there was a bit of nefarious handwork to get there, no way I could figure to do it programmatically that would run in my lifetime.

I do not save the relations amongst fams and indis across runs of plugins since they are not fixed and translatable, however, generations are. so, now I change the temporary root to that grandfather that is at -3, and as root, becomes 0, so does that translate that if I know that by program (I am trying to shorten this) I subtract -3 from the generations I have with me as root -(-3) and those are the new generations?
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28486
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: what is all this then?

Post by tatewise »

No, you add 3 to the existing generation numbers, because you added 3 to the grandfather to adjust from -3 to 0 to make him the root. So your current root becomes generation 3 below the grandfather.

You could try asking CP why FH cannot calculate all generation numbers for everyone in the same pool.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Post Reply