* Name Problems

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.
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Name Problems

Post by Ron Melby »

the number from FaG memorial must be aligned right (for stare and compare) it is immediately followed by the http://www.find.... (twice, once for buddy and once to check the formation of url so if dup or badly formed url I can click and go to it)
the space between the two is hard to look in, so I added two blanks to the end of the number.

No, format doesnt matter, I was just trying to understand the code... and what it is doing.

having done it another way in a code for many years that is my model that I understand, so to understand a slightly different model takes some time, and is a little hard to get the guts of the scam in my head.

I think that normally the Page 23 would not be what I want, but in this case, I do.....it would show (what for my purposes in this case would be) a malformed url
FH V.6.2.7 Win 10 64 bit
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Name Problems

Post by Ron Melby »

here is my completed code works pretty good and has been bench tested a bit. It is based on Gary Carsons plugin and all this is based on miketates work.

anyway, does some cool but specific stuff, so if you are tryng to learn some code, here is some. If you find errors, let me know, I will fix them.

Code: Select all

--[[
@title: Cemetery Table QD
@author: Ron Melby
@lastupdated: Apr 2018
@version: 1.0
@description: FaG Quick and Dirty
* INDI
* EVENT
* CEMETERY or Disposition
* MemNbr
* FaG Page
* Plot
]]

-- rtvSrcRcds
function rtvSrcRcds(SrcTag, ptrSOUR)
-- SrcTag:    Source being searched for
  local ptr          = fhNewItemPtr()
  local recordPtr    = fhNewItemPtr()
 
 ptr:MoveToFirstRecord('INDI')
  while ptr:IsNotNull() do
    if fhGetTag(ptr) == SrcTag then
      wrtTbls(ptr, ptrSOUR)
    end
    recordPtr:MoveToRecordItem(ptr)
    ptr:MoveNextSpecial()
 end
end

-- wrtTbls
function wrtTbls(ptr, ptrSOUR)
  local ptrINDI   = fhNewItemPtr()
  local ptrLink   = fhNewItemPtr()
  local ptrWork   = fhNewItemPtr()
  local ptrCEM    = fhNewItemPtr() 
  ptrLink         = fhGetValueAsLink(ptr)
    Sortname        = ' ' 
  if ptrLink:IsSame(ptrSOUR) then
  -- Matching Record Found Add to Tables.
     ptrINDI:MoveToRecordItem(ptr)
    
 -- Get INDI Record
    ptrWork:MoveToRecordItem(ptr)
    Name = fhGetItemText(ptrWork, "~.NAME:SURNAME_FIRST")
    NameSuffix = fhGetItemText(ptrWork,"~.NAME.NSFX")
    Sortname = (Name.. ' ' ..NameSuffix)
    table.insert(tblName, Sortname)
    table.insert(tblINDI, ptrINDI:Clone())
   
 -- FaG BURI or CREM
    ptrWork:MoveToParentItem(ptr)
    table.insert(tblEvent,fhGetTag(ptrWork))
 
 -- FaG Cemetery Addr or disposition
    TAG = '~.' ..(fhGetTag(ptrWork)) 
    CemAddr = (TAG.. '.ADDR')
    ptrWork:MoveTo(ptrINDI, CemAddr)
    if ptrWork:IsNull() then
	   CemAddr = (TAG.. '.NOTE2')
      ptrWork:MoveTo(ptrINDI, CemAddr)
    end
    table.insert(tblCEM, ptrWork:Clone())  

 -- FaG Memorial Number 
    ptrWork:MoveTo(ptr,'~.PAGE')
    local strWebPage = fhGetValueAsText(ptrWork)
    local strMemorial = strWebPage:gsub(".-(%d+).*","%1")
    table.insert(tblMML,(strMemorial.." "))
 -- FaG Web Page
    table.insert(tblPAGE,ptrWork:Clone())

  
 -- Plot information
    ptrWork:MoveTo(ptr,'~.NOTE2')
    table.insert(tblPlot,ptrWork:Clone())
  end
end

-- Main Code
-- Tables for Result Set
tblName   = {} -- formatted name
tblINDI   = {} -- record pointer
tblEvent  = {} -- BURI or CREM
tblCEM    = {} -- CemAddr or Event note
tblMML    = {} -- Memorial Number
tblPAGE   = {} -- FaG link
tblPlot   = {} -- plot from Source note

tblParm   = {} -- Source to find
-- Prompt for Source
tblParm = fhPromptUserForRecordSel('SOUR',1)

-- nothing chosen
if #tblParm == 0 then
  fhMessageBox('Plugin Cancelled')
  return
end

--if citation has no links 
local iCitations = fhCallBuiltInFunction('LinksTo', tblParm[1])
if iCitations == 0 then
  fhMessageBox('No Citations Found')
  return
end

ptrSOUR = tblParm[1]
rtvSrcRcds('SOUR', ptrSOUR)
if #tblINDI > 0 then
-- Output Tables built to Results Window
  fhOutputResultSetColumn("Person",   "text", tblName,  #tblName, 128, "align_left")
  fhOutputResultSetColumn("LnkNam",   "item", tblINDI,  #tblINDI, 128, "align_left", 2, true, "default", "buddy")
  fhOutputResultSetColumn("Event",    "text", tblEvent, #tblCEM,   24, "align_left")
  fhOutputResultSetColumn("Cemetery", "item", tblCEM,   #tblCEM,  296, "align_left", 1)
  fhOutputResultSetColumn("Mem#",     "text", tblMML,   #tblMML,  48, "align_left")
  fhOutputResultSetColumn("LnkMem",   "item", tblPAGE,  #tblPAGE, 156, "align_right", 3, true, "default", "buddy")
  fhOutputResultSetColumn("Page",     "item", tblPAGE,  #tblPAGE, 156, "align_left")
  fhOutputResultSetColumn("Plot",     "item", tblPlot,  #tblPlot, 248, "align_left")
else
  fhMessageBox('No Citations Found')
  return 
end

FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Name Problems

Post by tatewise »

I have a couple of initial comments.
The recordPtr variable inside rtvSrcRcds function serves no purpose.
After the discussion about Mem# column needing align_right, in your script it is align_left, so is that a mistake?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Name Problems

Post by Ron Melby »

no the right adjust is not a mistake, its where I left it when I could put two spaces behind it.

the recordptr is left over from some other copy of something, it would be nice to have a strict in depth lint for lua but I dont know where one is.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Name Problems

Post by tatewise »

But if you are using align_left why do you add the two spaces?
They are only needed with align_right to avoid merging with next column.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
tatewise
Megastar
Posts: 28341
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Name Problems

Post by tatewise »

Ron, would you like the Result Set to identify the duplicate use of Memorial numbers?

In your Tables for Result Set add tblTwin = {} to monitor the duplicates.

Then in function wrtTbls(...) just before Plot information insert this code:

Code: Select all

 -- Note duplicates
    local strTwin = ""
    if strWebPage ~= strMemorial then
      if tblTwin[strMemorial] then
        strTwin = strMemorial
        tblTwin[tblTwin[strMemorial]] = strTwin
      else
        tblTwin[strMemorial] = #tblMML
      end
    end
    table.insert(tblTwin,strTwin)
Also in Output Tables built to Results Window you need:
fhOutputResultSetColumn("Twin#", "text", tblTwin, #tblMML, 48, "align_left")

In that code, tblTwin[strMemorial] logs the index position (#tblMML) in Result Set for each new Memorial number found.
If the same Memorial number is found again then the tblTwin original Result Set entry and the current tblTwin entry are both set to the Memorial number (strTwin).
This illustrates a useful trick of tables where both textual indexes (strMemorial number) and numerical indexes (Result Set entry) can coexist in the same table (tblTwin).
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Name Problems

Post by Ron Melby »

now THAT's computing!! thanks miketate

I thought I would be slick and do this:

if #tblTwin > 0 then
fhOutputResultSetColumn("Twin#", "text", tblTwin, #tblMML, 52, "align_left")
end

but it wrote the blank columns with header anyway.

do I have to do separate result columns with switching logic?

if #tblCem > 0 and #tblTwin >0
one set results
elseif
#tblCEM > 0
other set results
end

just the output columns are information in this little vignette.


I just realized, blank or not, #tblTwin = #tblMML so I made

global in the tables section
ix = 0


local strDup = ""
if strWebPage ~= strMemorial then
if tblDup[strMemorial] then
strDup = strMemorial
tblDup[tblDup[strMemorial]] = strDup
ix = ix + 1 ******ADDED
else
tblDup[strMemorial] = #tblMML
end
end
table.insert(tblDup,strDup)

and it works as expected. Like I said, takes awhile to catch up to what your alg is, I am still way down at having syntax trouble. The reason you are seeing all the name changes, is --- as I debug it and understand it, I then change it so I am not looking at the same stuff repeatedly.

And this is why I post stuff that is solved later, and then update it, because well over 80% of the time, I cant solve it myself.
.
FH V.6.2.7 Win 10 64 bit
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Name Problems

Post by Ron Melby »

Now, I hope you can tell me a plugin that does heavy FAM processing and FAMC AND FAMS after that, I start a new thread on this new one.
FH V.6.2.7 Win 10 64 bit
Post Reply