* quick and easy relation (hopefully useful) plugin

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

quick and easy relation (hopefully useful) plugin

Post 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
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28414
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: quick and easy relation (hopefully useful) plugin

Post 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.
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: quick and easy relation (hopefully useful) plugin

Post 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.
FH V.6.2.7 Win 10 64 bit
User avatar
johnmorrisoniom
Megastar
Posts: 904
Joined: 18 Dec 2008 07:40
Family Historian: V7
Location: Isle of Man

Re: quick and easy relation (hopefully useful) plugin

Post 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
User avatar
tatewise
Megastar
Posts: 28414
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: quick and easy relation (hopefully useful) plugin

Post by tatewise »

No, because under the hood they all use the same =Relationship() function.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: quick and easy relation (hopefully useful) plugin

Post 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"
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
User avatar
tatewise
Megastar
Posts: 28414
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: quick and easy relation (hopefully useful) plugin

Post by tatewise »

I stand corrected.

A Plugin could do something similar, but it would be more complex than Ron's example.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
Post Reply