* Copy Child Branch Fields code snippet for FH V7

Writing and using plugins for Version 5 and above.
Post Reply
User avatar
tatewise
Megastar
Posts: 20104
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Copy Child Branch Fields code snippet for FH V7

Post by tatewise » 14 Jan 2021 14:35

The KB code snippet Copy Child Branch Fields fails for FH V7 scenarios involving rich text Notes and source citation metafields.
The function CopyBranch(...) needs amending as below:

Code: Select all

function CopyBranch(ptrSource,ptrTarget)
  local strTag = fhGetTag(ptrSource)
  if strTag == "_FMT" then return end    -- Skip rich text format code
  if strTag == "_FIELD" then             -- Substitute metafield shortcut
    strTag = fhGetMetafieldShortcut(ptrSource)
  end
  local ptrNew = fhCreateItem(strTag,ptrTarget,true)
  if ptrNew:IsNull() then return end     -- Escape if item not created
  fhSetValue_Copy(ptrNew,ptrSource)
  CopyChildren(ptrSource,ptrNew)
end -- function CopyBranch
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
ColeValleyGirl
Megastar
Posts: 2193
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Copy Child Branch Fields code snippet for FH V7

Post by ColeValleyGirl » 14 Jan 2021 14:50

Mike, please use the KB contact form for corrections such as this -- thanks.

User avatar
tatewise
Megastar
Posts: 20104
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Copy Child Branch Fields code snippet for FH V7

Post by tatewise » 14 Jan 2021 15:14

OK, but thought it worthwhile publicising here as I don't suppose authors will go checking the KB for changes
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
PeterR
Megastar
Posts: 1107
Joined: 10 Jul 2006 16:55
Family Historian: V7
Location: Northumberland, UK

Re: Copy Child Branch Fields code snippet for FH V7

Post by PeterR » 15 Jan 2021 10:57

Thanks for this update, Mike, which I've now used to revise my old plugin "Clone any Record", following a request from a keen user. However, I am more than a little puzzled by Copy Child Branch Fields which was updated at least twice yesterday and now contains four occurrences of "<wbr>".
Peter Richmond (researching Richmond, Bulman, Martin, Driscoll, Baxter, Hall, Dales, Tyrer)

User avatar
ColeValleyGirl
Megastar
Posts: 2193
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Copy Child Branch Fields code snippet for FH V7

Post by ColeValleyGirl » 15 Jan 2021 11:10

Fixed (unless Mike says differently).

I know he and Colin had a bit of to-and-fro trying to get it correct...

User avatar
tatewise
Megastar
Posts: 20104
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: Copy Child Branch Fields code snippet for FH V7

Post by tatewise » 15 Jan 2021 11:17

Sorry. The KB administrator had difficulty understanding what needed updating.
Helen requested I use the KB Contact Form but that upset the script layout indents, etc, adding further confusion.
There only seems to be one <wbr> remaining now. Why not use the KB Contact Form to report that mistake?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
ColeValleyGirl
Megastar
Posts: 2193
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Copy Child Branch Fields code snippet for FH V7

Post by ColeValleyGirl » 15 Jan 2021 11:23

Don't bother logging it -- I've fixed it.

Post Reply