* ADOP and PEDI tags.

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: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

ADOP and PEDI tags.

Post by Ron Melby »

Code: Select all

function rtvfID(fptr)

  local var     = type(fptr)
  if var == 'userdata' then
    local ptrtype = fhGetTag(fptr)

    if ptrtype == 'FAMC' 
    or ptrtype == 'FAMS' then
      fptr = fhGetValueAsLink(fptr) 
    end
  elseif var == 'number' then
    local xptr = fhNewItemPtr()
    xptr:MoveToRecordById('FAM', fptr)
    fptr = xptr:Clone()
  else
    return
  end

  local mdptr = fhNewItemPtr()
  local fmdat = fhNewDate()
  mdptr = fhGetItemPtr(mdptr, '~.MARR.DATE:COMPACT')
  if mdptr:IsNotNull() then
    fmdat = fhGetValueAsDate(mdptr)
  end
  
  local ddptr = fhNewItemPtr()
  local dmdat = fhNewDate()
  ddptr = fhGetItemPtr(ddptr, '~.MARR.DATE:COMPACT')
  if ddptr:IsNotNull() then
    dmdat = fhGetValueAsDate(ddptr)
  end

  local _cs = 
  {
    fID   = fhGetRecordId(fptr), 
    fptr  = fptr:Clone(), 
    mdptr = mdptr:Clone(),
    fmdat = fmdat,
    ddptr = ddptr:Clone(),
    dmdat = dmdat,
  }

  return _cs
end -- fn matfID


function rtvFAMCtbl(iptr) 
  local ptrFAMC = fhNewItemPtr() -- all famc
  local lnkFAMC = fhNewItemPtr() -- FAM pointer
  local ptrADOP = fhNewItemPtr() -- ADOP
  local lnkADOP = fhNewItemPtr()
  local this    = fhNewItemPtr()
  local pedi    = ''
  local famc    = {}
  local fc      = 0

  ptrFAMC:MoveTo(iptr, '~.FAMC')
  while ptrFAMC:IsNotNull() do
    --   lnkFAMC = fhGetValueAsLink(ptrFAMC)
    pedi = fhGetItemText(iptr, '.PEDI')
    ptrADOP = fhGetItemPtr(iptr, '~.ADOP.FAMC')
    if ptrADOP:IsNotNull() then
      lnkADOP = fhGetValueAsLink(ptrADOP)
      _ac = rtvfID(lnkADOP)
    end
    fc = fc + 1
    famc[fc] = rtvfID(ptrFAMC)

    ptrFAMC:MoveNext('SAME_TAG')
  end
  return famc
end -- fn rtvFAMCtbl
I am probably staring at the elegant solution and have been for some time, but I never have worked this out satisfactorily, and it is a neccessity now:

the problem lies with ptrADOP and pedi. I am not sure I can desribe it.
this is part of a much larger program.

forget for the moment that I will return a table with from 1 ... n entries in order that is not encoded yet:

famc = (will be)
{}

or

[1] {
fID = fhGetRecordId(ptrFAMC),
fpa = ['', 'PEDI' 'ADOP'],
fpp = ['', 'HUSB' 'WIFE', 'BOTH'],
}

or

[1] {
fID = fhGetRecordId(ptrFAMC),
fpa = ['', 'PEDI' 'ADOP'],
fpp = ['', 'HUSB' 'WIFE', 'BOTH'],
}


[2] {
fID = fhGetRecordId(ptrFAMC),
fpa = ['', 'PEDI' 'ADOP'],
fpp = ['', 'HUSB' 'WIFE', 'BOTH'],
}

and so on.

I cannot think of an efficient way to link either ADOP or PEDI to the correct FAMC in one fell swoop.
It seems that I sort of need a ptrCPLX = fhGetItemPtr(iptr, ptrFAMC, '~.ADOP' sort of thing... something simple is escaping me.

my tags are all in the form:
1 FAMC @F132@
2 PEDI Foster

1 ADOP
2 FAMC @F1796@
3 ADOP BOTH


Thanks.
FH V.6.2.7 Win 10 64 bit
Post Reply