Page 1 of 1

quick and easy relation (hopefully useful) plugin

Posted: 23 Jun 2019 19:56
by Ron Melby
if you have ever been asked what two peoples relations are, and you don't want to change roots and then hunt, here is a very simple plugin for you:

Code: Select all

function sltIRCD()
  tblParm = fhPromptUserForRecordSel('INDI', 2)
  if #tblParm ~= 2 then
    return false
  end 

  p1 = tblParm[1] 
  p2 = tblParm[2] 
  return true
end --fn sltIRCD

function rtvNAME(iptr)
  local Name    = ''
  local NameSfx = ''
  Name  = fhGetItemText(iptr,'~.NAME:SURNAME_FIRST')
  NameSfx = fhGetItemText(iptr,'~.NAME.NSFX')
  Name = Name .. NameSfx
  return Name
end -- fn rtvNAME

tblout = {}
cwbtw = 0

-- Main()
rc = sltIRCD()
if rc ==  false then
  return
end

NAM1 = rtvNAME(p1)
rlt1 = fhCallBuiltInFunction('Relationship', p1, p2, 'TEXT', 1)
if rlt1 == '' then
  rlt1 = 'none'
end

NAM2 = rtvNAME(p2)
rlt2 = fhCallBuiltInFunction('Relationship', p2, p1, 'TEXT', 1)
if rlt2 == '' then
  rlt2 = 'none'
end

txt1 = (NAM1 .. "'s relation to " .. NAM2 .. ' is ' .. rlt1)
txt1 = txt1:gsub( ' \'s', '\'s' )           
txt1 = txt1:gsub( '  ', ' ')                
table.insert(tblout, txt1)
cwbtw = math.max(cwbtw, #txt1)

txt2 = (NAM2 .. "'s relation to " .. NAM1 .. ' is ' .. rlt2)
txt2 = txt2:gsub( ' \'s', '\'s' )           
txt2 = txt2:gsub( '  ', ' ')                
table.insert(tblout, txt2)
cwbtw = math.max(cwbtw, #txt2)

cwbtw = ((cwbtw + 1)* 4)

fhOutputResultSetColumn('Relation', 'text', tblout, #tblout,cwbtw, 'align_left')

return

Re: quick and easy relation (hopefully useful) plugin

Posted: 23 Jun 2019 21:30
by tatewise
Why do you believe that is better than Tools > How Related that gives multiple relationships and diagrams too?

It is possible to use the =Relationship() function in Queries, etc, with any two Individual records ~ no need to involve File Root.

Re: quick and easy relation (hopefully useful) plugin

Posted: 23 Jun 2019 23:35
by Ron Melby
Why do you believe I believe it is better?

is Lua, simple, and may or may not give someone the idea to try to code.

but I believe it is better than a query, You got me there.

Re: quick and easy relation (hopefully useful) plugin

Posted: 24 Jun 2019 10:37
by johnmorrisoniom
Ron,
Would you plugin cover cases of two people in the same pool whose relationship cannot be shown by the built in tool? ie separated by more than one marriage

Re: quick and easy relation (hopefully useful) plugin

Posted: 24 Jun 2019 10:50
by tatewise
No, because under the hood they all use the same =Relationship() function.

Re: quick and easy relation (hopefully useful) plugin

Posted: 24 Jun 2019 15:04
by Jane
johnmorrisoniom wrote:Ron,
Would you plugin cover cases of two people in the same pool whose relationship cannot be shown by the built in tool? ie separated by more than one marriage
The how related tool does show this eg

"No direct relationship found between Robert Henry TAUBMAN and Nicholas BARETT.

Robert Henry TAUBMAN is father of Stephen TAUBMAN and Stephen TAUBMAN is husband of sister of wife of Nicholas BARETT"

Re: quick and easy relation (hopefully useful) plugin

Posted: 24 Jun 2019 16:42
by tatewise
I stand corrected.

A Plugin could do something similar, but it would be more complex than Ron's example.