RelationCodes provides all the codes from the RelationCode() library function in a convenient table list by using the Relationship() library function with its "CODE" parameter.
Requires: None
Code
-
function RelationCodes( ptrA, ptrB, rel ) local mask = "Gens%. Up=(%d+), Gens%. Down=(%d+), Half=(%d+), Spouse Start=(%d+), Spouse End=(%d+)" local code = "" if ptrA:IsNotNull() and ptrB:IsNotNull() then code = fhCallBuiltInFunction( "Relationship", ptrA, ptrB, "CODE", rel or 1) end local gensUp, gensDown, half, spouseStart, spouseEnd = string.match( code, mask ) return { GensUp=gensUp or ""; GensDown=gensDown or ""; Half=half or ""; SpouseStart=spouseStart or ""; SpouseEnd=spouseEnd or ""; } end -- function RelationCodes
Usage
-
local ptrX = fhNewItemPtr() ptrX:MoveToRecordById("INDI",1) local ptrY = fhNewItemPtr() ptrY:MoveToRecordById("INDI",6) local list = RelationCodes( ptrX, ptrY ) for k, v in pairs (list) do print( k, " = ", v ) end
produces such as
-
SpouseEnd = 0 SpouseStart = 0 Half = 0 GensUp = 3 GensDown = 1