* Plugin Help

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

Re: Plugin Help

Post by Ron Melby »

Code: Select all

---------------------------------------
-- Function: CopyChildBranch
---------------------------------------
function CopyChildBranch(ptrSrc, ptrTargParent)
local ptrNew = fhCreateItem(fhGetTag(ptrSrc), ptrTargParent)
fhSetValue_Copy(ptrNew, ptrSrc)
local strTag = fhGetTag(ptrSrc)
if strTag == "SOUR2" then                              -- Found a Source Note
  strSour2 = fhGetValueAsText(ptrSrc)
  strRecId = string.match(strSour2, "@@S(%d+)@@" )     -- Extract Rec Id from Source Note
  local ptrRec = fhNewItemPtr()
  ptrRec:MoveToRecordById( "SOUR", strRecId)           -- Obtain pointer to Source Record
  local ptrNew = fhCreateItem( "SOUR", ptrTargParent ) -- Create the Source Link
  fhSetValueAsLink( ptrNew, ptrRec)
else
  local ptrNew = fhCreateItem( strTag, ptrTargParent)  -- Otherwise just copy original tag
  fhSetValue_Copy(ptrNew, ptrSrc)
end
CopyChildren_FromTo(ptrSrc, ptrNew)
end
 
---------------------------------------
-- Function: CreateCopyChildren_FromTo
---------------------------------------
 function CopyChildren_FromTo(ptrFrom, ptrTo)
 local ptrF = fhNewItemPtr()
 ptrF = ptrFrom:Clone()
 ptrF:MoveToFirstChildItem(ptrF)
 while ptrF:IsNotNull() do
   CopyChildBranch(ptrF, ptrTo)
   ptrF:MoveNext()
 end
 end

--main
 local ptrINDI = fhNewItemPtr()
 ptrINDI:MoveToFirstRecord("INDI")
 while ptrINDI:IsNotNull() do                     
   local ptrUDF = fhGetItemPtr(ptrINDI,"INDI.NICK") 
   if ptrUDF:IsNotNull() then                     
     local ptrTemp = fhNewItemPtr()
     local ptrName = fhGetItemPtr(ptrINDI,"INDI.NAME")
     if ptrName:IsNull() then                    
       ptrName = fhCreateItem("NAME",ptrINDI)
     end
     local ptrNick = fhGetItemPtr(ptrName,"~.NICK")
     if ptrNick:IsNull() then                    
       str = fhGetValueAsText(ptrUDF)
       str = string.gsub(str,'"','')
       ptrNick = fhCreateItem("NICK",ptrName)    
       fhSetValueAsText(ptrNick,str)
        local ptrTemp = fhHasChildItem(ptrUDF) 
       if fhHasChildItem(ptrUDF) then   
         local ptrInsert = fhNewItemPtr()
         CopyChildren_FromTo(ptrUDF, ptrInsert) 
       end
       fhDeleteItem(ptrUDF)               -- delete UDF
     end
   end
   ptrINDI:MoveNext()
 end
This code fixes every UDF Nick case in my file. And it does it (audited) correctly. Thanks for the massive help tatewise, David. Peter.

so now, I have this situation (many) :

0 @I322@ INDI
1 NAME Annabelle /Ames/
2 SOUR @S1467383572@
3 PAGE Year: 1910; Census Place: Township 139, Stark, North Dakota; Roll: T624_1148; Page: 5B; Enumeration District: 0170; FHL microfilm: 1375161
2 SOUR @S1467383564@
2 SOUR @S1467383571@
3 PAGE Year: 1900; Census Place: Township 139, Stark, North Dakota; Roll: 1232; Page: 27B; Enumeration District: 0163; FHL microfilm: 1241232
2 SOUR @S1467383580@
3 PAGE Year: 1880; Census Place: Fisher, Polk, Minnesota; Roll: 629; Family History Film: 1254629; Page: 354C; Enumeration District: 204; Image: 0312
2 SOUR @S1467383566@
3 PAGE Year: 1930; Census Place: McNulty, Columbia, Oregon; Roll: 1941; Page: 3A; Enumeration District: 0013; Image: 629.0; FHL microfilm: 2341675
2 SOUR @S1467383560@
3 PAGE Year: 1860; Census Place: Dunn, Dunn, Wisconsin; Roll: M653_1407; Page: 4; Image: 9; Family History Library Film: 805407
2 SOUR @S1467382567@
1 SEX F <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*******
2 SOUR @@S1467383566@@
3 PAGE Year: 1930; Census Place: McNulty, Columbia, Oregon; Roll: 1941; Page: 3A; Enumeration District: 0013; Image: 629.0; FHL microfilm: 2341675

where the UDF SEX just shows up in some random location in the source list.
using
fhMoveItemBefore(ptrSEX,ptrBIRT)
and use the getchildrenfrom_to do I have to know the SOURnumber ie SOUR12 (whatever) or can I just addItem of type (INDI.NAME.SOUR} if you follow that shorthand?
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28435
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Plugin Help

Post by tatewise »

Assuming you want the UDF Source to become a Name Source then use:

CopyChildren_FromTo(ptrUDF, ptrName) why are you messing about with ptrInsert?
Both ptrUDF and ptrName are input parameters defining the From and To fields.

Also modify CopyChildBranch as I showed earlier.

Yes, the debugger correctly shows @S1234567890@ because as I said @@ in the GEDCOM means a single @.
So on reflection use string.match( strSour, "@S(%d+)@" )

Not sure how you code is working but if you are happy then OK.

To move the SEX Source to a Name Source then use the same Plugin script and replace NICK with SEX.
Use new code to create proper SEX, and CopyChildren_FromTo(ptrUDF, ptrName) as before.
No need to move SEX before BIRT.
However, I am surprised SEX is a UDF. Are you sure it is not _SEX ?
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: Plugin Help

Post by Ron Melby »

CopyChildren_FromTo(ptrUDF, ptrINDI) why are you messing about with ptrInsert?

That is a leftover declare from juking code around and debugging that does not one thing, as you can see. I will remove it.
unless I have missed a post I have modified it, copied directly from your post.

Ah, new lightbulb SOUR2 = 2<<<<<<< SOUR @S1@

they show up as INDI.SEX.SOUR ...
and the lines you see of raw gedcom are after being in FH and saved.

hold up, its the SOUR itself that is hosed up, not the sex. I have to investigate more.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28435
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Plugin Help

Post by tatewise »

The code you posted does not work - I tried it - so your Plugin must be somewhat different.

The INDI.SEX tag is perfectly valid.
It is the sub-field INDI.SEX.SOUR that is a UDF.

So all you need is to find the INDI.SEX (instead of INDI.NICK) and use CopyChildren_FromTo(ptrSEX,ptrName).
Do NOT create any new fields.
Do NOT delete the SEX field.

BTW:
SOUR2 refers to Source local Note text
SOUR refers to Source Link to Source record
similarly
NOTE2 refers to Note local text
NOTE refers to Note link to Note record
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: Plugin Help

Post by Ron Melby »

I dont believe I posted the wrong one, but just in case:

Code: Select all

---------------------------------------
-- Function: CopyChildBranch
---------------------------------------
function CopyChildBranch(ptrSrc, ptrTargParent)
local ptrNew = fhCreateItem(fhGetTag(ptrSrc), ptrTargParent)
fhSetValue_Copy(ptrNew, ptrSrc)
local strTag = fhGetTag(ptrSrc)
if strTag == "SOUR2" then                              -- Found a Source Note
  strSour2 = fhGetValueAsText(ptrSrc)
  strRecId = string.match(strSour2, "@S(%d+)@" )     -- Extract Rec Id from Source Note
  local ptrRec = fhNewItemPtr()
  ptrRec:MoveToRecordById( "SOUR", strRecId)           -- Obtain pointer to Source Record
  local ptrNew = fhCreateItem( "SOUR", ptrTargParent ) -- Create the Source Link
  fhSetValueAsLink( ptrNew, ptrRec)
else
  local ptrNew = fhCreateItem( strTag, ptrTargParent)  -- Otherwise just copy original tag
  fhSetValue_Copy(ptrNew, ptrSrc)
end
CopyChildren_FromTo(ptrSrc, ptrNew)
end
 
---------------------------------------
-- Function: CreateCopyChildren_FromTo
---------------------------------------
 function CopyChildren_FromTo(ptrFrom, ptrTo)
 local ptrF = fhNewItemPtr()
 ptrF = ptrFrom:Clone()
 ptrF:MoveToFirstChildItem(ptrF)
 while ptrF:IsNotNull() do
   CopyChildBranch(ptrF, ptrTo)
   ptrF:MoveNext()
 end
 end

--main
 local ptrINDI = fhNewItemPtr()
 ptrINDI:MoveToFirstRecord("INDI")
 while ptrINDI:IsNotNull() do                     
   local ptrUDF = fhGetItemPtr(ptrINDI,"INDI.NICK") 
   if ptrUDF:IsNotNull() then                     
     local ptrTemp = fhNewItemPtr()
     local ptrName = fhGetItemPtr(ptrINDI,"INDI.NAME")
     if ptrName:IsNull() then                    
       ptrName = fhCreateItem("NAME",ptrINDI)
     end
     local ptrNick = fhGetItemPtr(ptrName,"~.NICK")
     if ptrNick:IsNull() then                    
       str = fhGetValueAsText(ptrUDF)
       str = string.gsub(str,'"','')
       ptrNick = fhCreateItem("NICK",ptrName)    
       fhSetValueAsText(ptrNick,str)
        local ptrTemp = fhHasChildItem(ptrUDF) 
       if fhHasChildItem(ptrUDF) then   
         CopyChildren_FromTo(ptrUDF, ptrINDI) 
       end
       fhDeleteItem(ptrUDF)               -- delete UDF
     end
   end
   ptrINDI:MoveNext()
 end
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28435
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Plugin Help

Post by tatewise »

Yes, that is much better.
Although that is moving the UDF Source to the Individual record as a whole (ptrINDI) and not the Name field (ptrName) as your earlier posting suggested.

Also the first two lines in function CopyChildBranch(ptrSrc, ptrTargParent) must be deleted, as they effectively replicate the later two lines after else and may damage your data.
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: Plugin Help

Post by Ron Melby »

fixed, although it didnt seem to hurt.

I had about 20 versions, as I was learning...NickFix, FixNick, FIXNICK.... ad nauseam, and the two lines must have been in the original steal and I was between cleans and different lines in each...and I missed them, thanks.

the sources that were under nick were easier to move to whole record, because I know what I want in whole records, really, it would be easier to move all the sources under name to whole record as well. If you look at because most of the files I talk about come from a rellie on ancestry who has a 'less than optimal way' of contructing records, often puts CENS records in NAME quite often those NAME.SOUR records are duplicates of actual CENS and really dont provide additional evidence for NAME in any useful way. So imagine that I have a records list from my file (that I have worked a long time on to clean as you well know.) Thats screen and her records list on screen two, and hit the all button on each in place, then I have that and something like this...
1 NAME
all that crap
1 BIRT
SOUR miketate
1 DEAT
SOUR miketate
1 BURI
SOUR miketate

yanno what SOUR miketate provided info on the whole record, delete the EVENT sources and put it on whole, then the all that crap should be looked at on the whole record, because sometimes a CENS SOUR (WHOLE THING) will not be in a CENS record and easier to see that tree in the forest and copy it in from whole to CENS, then hit the whole record property sosurce box and say, doesnt belong in the whole record XXXXXXXXXXXXXXXXXXXX



So, a great deal of this is repetitive but consistent wrongs to make right. In fact, I am thinking about writing that baby right now, and just be done with it. its nearly the same as the one I have for FixNick my first official plugin. 6924 individual records in that file, I am at about 2700 and she has 3 and 4 duplicates of some of them. Ancestry hides a lot of puke.
FH V.6.2.7 Win 10 64 bit
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Plugin Help

Post by Ron Melby »

Code: Select all

---------------------------------------
-- Function: CopyChildBranch
---------------------------------------
function CopyChildBranch(ptrSrc, ptrTargParent)
local strTag = fhGetTag(ptrSrc)
if strTag == "SOUR2" then                              -- Found a Source Note
  strSour2 = fhGetValueAsText(ptrSrc)
  strRecId = string.match(strSour2, "@S(%d+)@" )     -- Extract Rec Id from Source Note
  local ptrRec = fhNewItemPtr()
  ptrRec:MoveToRecordById( "SOUR", strRecId)           -- Obtain pointer to Source Record
  local ptrNew = fhCreateItem( "SOUR", ptrTargParent ) -- Create the Source Link
  fhSetValueAsLink( ptrNew, ptrRec)
else
  local ptrNew = fhCreateItem(strTag, ptrTargParent)  -- Otherwise just copy original tag
  fhSetValue_Copy(ptrNew, ptrSrc)
end
CopyChildren_FromTo(ptrSrc, ptrNew)
end
 
---------------------------------------
-- Function: CreateCopyChildren_FromTo
---------------------------------------
 function CopyChildren_FromTo(ptrFrom, ptrTo)
 local ptrF = fhNewItemPtr()
 ptrF = ptrFrom:Clone()
 ptrF:MoveToFirstChildItem(ptrF)
 while ptrF:IsNotNull() do
   CopyChildBranch(ptrF, ptrTo)
   ptrF:MoveNext()
 end
 end

--main
 local ptrINDI = fhNewItemPtr()
 ptrINDI:MoveToFirstRecord("INDI")
 while ptrINDI:IsNotNull() do                     
   local ptrName = fhGetItemPtr(ptrINDI,"INDI.NAME")
   local ptrSrcGob = fhGetItemPtr(ptrName,"~.SOUR")
   if not ptrSrcGob:IsNull() then                    
     str = fhGetValueAsText(ptrSrcGob)
     fhSetValueAsText(ptrSrcGob,str)
     local ptrTemp = fhHasChildItem(ptrSrcGob) 
     if fhHasChildItem(ptrSrcGob) then   
       CopyChildren_FromTo(ptrSrcGob, ptrINDI) 
       fhDeleteItem(ptrSrcGob)               
     end
   end
 ptrINDI:MoveNext()
 end
function CopyChildBranch(ptrSrc, ptrTargParent)
else
local ptrNew = fhCreateItem(strTag, ptrTargParent) -- Otherwise just copy original tag

So, I am moving NAME.SOUR to <whole record> .SOUR
it failed on this record

0 @I8@ INDI
1 NAME Harry E. /Sutherland/
2 SOUR @S131@
3 PAGE Pengry, Skagit county, Washington
3 DATA
4 TEXT Sutherland, Harry, head, rents age 25, born Wathington, father born Minnesota, mother born unknown.

@ TEXT because ptrTargParent = nil.

I don't even come close to understanding it, it was fine for PAGE, and DATA. I dont even comprehend how I left that pointer. Have I told you that I just wrote my first actual working program in LUA today? And I only understood it thru a mirror; darkly.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28435
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Plugin Help

Post by tatewise »

You don't need some of the complex parts because this is all good GEDCOM without UDF.

Code: Select all

---------------------------------------
-- Function: CopyChildBranch
---------------------------------------
function CopyChildBranch(ptrSrc, ptrTargParent)
  local strTag = fhGetTag(ptrSrc)
  local ptrNew = fhCreateItem(strTag, ptrTargParent)
  fhSetValue_Copy(ptrNew, ptrSrc)
  CopyChildren_FromTo(ptrSrc, ptrNew)
end
 
---------------------------------------
-- Function: CreateCopyChildren_FromTo
---------------------------------------
 function CopyChildren_FromTo(ptrFrom, ptrTo)
 local ptrF = fhNewItemPtr()
 ptrF = ptrFrom:Clone()
 ptrF:MoveToFirstChildItem(ptrF)
 while ptrF:IsNotNull() do
   CopyChildBranch(ptrF, ptrTo)
   ptrF:MoveNext()
 end
 end

--main
 local ptrINDI = fhNewItemPtr()
 ptrINDI:MoveToFirstRecord("INDI")
 while ptrINDI:IsNotNull() do                     
   local ptrName = fhGetItemPtr(ptrINDI,"INDI.NAME")
   local ptrSrcGob = fhGetItemPtr(ptrName,"~.SOUR")
   if ptrSrcGob:IsNotNull() then
       CopyChildBranch(ptrSrcGob, ptrINDI) 
       fhDeleteItem(ptrSrcGob)               
   end
 ptrINDI:MoveNext()
 end
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: Plugin Help

Post by Ron Melby »

because it has been a brief respite, we will grab a hold of our bearings.
I am going thru indi records, finding if the name has sources, and if they do, attach those to the <whole record> and remove them from the NAME record...

--main
local ptrINDI = fhNewItemPtr()
ptrINDI:MoveToFirstRecord("INDI")
while ptrINDI:IsNotNull() do
local ptrName = fhGetItemPtr(ptrINDI,"INDI.NAME")
local ptrSrcGob = fhGetItemPtr(ptrName,"~.SOUR")
>>>>>>
while ptrSrcGob:IsNotNull() then
local ptrSrcGob = fhGetItemPtr(ptrName,"~.SOUR")
if ptrSrcGob:isNotNull() then
CopyChildren_FromTo(ptrSrcGob, ptrINDI)
fhDeleteItem(ptrSrcGob)
end
end
>>>>>>>>>>>>>>
ptrINDI:MoveNext()
end

Overloaded for a bit, had to take a day.
dont I have to loop this part to get them all >>>>>
with a while rather than an if? and add these lines inside the while loop
because it looks like it will it just copy one per as is, and if it does all, why does it do them all?
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28435
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Plugin Help

Post by tatewise »

Yes Ron, you are absolutely correct, but there is a gotcha.
You cannot easily copy the source and delete the source in the same loop without upsetting the loop pointer.

The loop is :

Code: Select all

local ptrName = fhGetItemPtr(ptrINDI,"INDI.NAME")
local tblSrcGob = {}
local ptrSrcGob = fhGetItemPtr(ptrName,"~.SOUR")
while ptrSrcGob:IsNotNull() do  -- Loop through all SOUR sub-fields of NAME
   CopyChildren_FromTo( ptrSrcGob, ptrINDI )
   table.insert( tblSrcGob, ptrSrcGob:Clone() )  -- Save pointer clone
   ptrSrcGob:MoveNext("SAME_TAG")
end
for intSrcGob, ptrSrcGob in ipairs (tblSrcGob) do
   fhDeleteItem(ptrSrcGob)  -- Now delete the unwanted SOUR tags
end
See Sample Plugin Scripts > List All Individuals using all possible Surnam for example of MoveNext("SAME_TAG") loop.
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: Plugin Help

Post by Ron Melby »

Yes. That makes sense. Probably why my SOURCES are disappearing off the face of the earth I have one and only one in my file that has a single NAME.SOUR) that I am moving to INDI.SOUR, and when that name comes up I debug line by line, and the SOUR is nowhere to be found.........I know in my sleep and will when I am dead, undo plugin changes..... I knocked around with it for a long while getting absolutely and convolutedly lost. I know exactly how to do that in another language, but I am new. Now that you have written it out.............I see it. Although I never would have found that "SAME_TAG" thing. and rather than write another pointer routine the table and mass delete is more along how I would think.
So, thanks, that is a week of knocking my head around on figuring out what is going on, although I had the idea that it was to do with pointer exhaustion.



New Thread or keep it here??????
I also have a scam (and its coding a plugin) that would need to read @_PLAC records, and store them in a table across open and closes. I see map life facts has some code to steal.

so, say in my incoming files I have
Bethersden, Kent
Bethersden, UK
Bethersden, En.
Blahblahblah....making a terrible mess..........
But I have a pristine Place file, since I have made one... in that GEDCOM I have talked about here for years.
lets say it has an alphabetical sort (the good one)
and it has a field called link.
so I have

call this table/File: CODEX
Link Plac (same holds for addy)
1 Bethersden, West Ashford, Kent, EN, GBR
so I have my nasty fields
and write a side by side subfile looks like the table output from a query a list of records, scrollable
and then have an indicator to turn on and off display on bad file where link is filled in.

So, file is built (I know, magic).
1 Bethersden, Kent
1 Bethersden, UK
1 Bethersden, En.
1 Blahblahblah....making a terrible mess..........
so, I could ptrINDI
ptrPLAC actual place records.
find in bad table (LOL, BIG MAGIC AT THIS POINT)
if no number or not not found, continue to next plac (or Addy)
if BadPlac has number get entry from CODEX
write with standard place, if no number or not not found, cont
I think it would either be several programs or very large like MapFacts.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28435
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Plugin Help

Post by tatewise »

The easiest way to save data from one FH session to another is to save it in a file and load it back in next session.

The most flexible technique is to capture your data in a table structure.
Then http://lua-users.org/wiki/SaveTableToFile has a table.save( table , filename ) and table.load( filename ).
Insert its script at the top of your Plugin.

To obtain the full filename path and call the save and load functions use the following:

local strFolder = fhGetContextInfo("CI_PROJECT_DATA_FOLDER") -- to keep local to one project
local strFilename = strFolder.."\\MyData.dat"

local strFolder = fhGetContextInfo("CI_APP_DATA_FOLDER") -- to share between projects
local strFilename = strFolder.."\\Plugin Data\\MyData.dat"

local tblMyData = { A="B"; } -- this is where to keep your Place details

table.save( tblMyData, strFilename ) -- save the table to file

tblMyData = table.load( strFilename ) -- load the table from file
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: Plugin Help

Post by Ron Melby »

thats pretty much what I am looking for, from there--- keys (I am sure that is doable, I just dont know the language yet) one way is to call an sql function I suppose. I figure it will be self healing because once my entries are done once, and do some maintenance, I will only have a few random places and addresses that would need fixing, much like map facts.
Clean up a file in one fell swoop.
FH V.6.2.7 Win 10 64 bit
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: Plugin Help

Post by Ron Melby »

Well, all I that has to wait. I am back at moving all sources from sub-INDI.NAME to sub-INDI (making them whole record sources.
the code as is as provided by tatewise is working all the way through except it does not put the records out for whole record.

they delete from INdi.name.sour correcty where they are at level 2-3-4-5 in their gob, but do not add to <whole record. where they should be at level-1-2-3-4

foolishly I have made the code thus:

while ptrSrcGob:IsNotNull() do -- all SOUR of NAME
CopyChildren_FromTo( ptrSrcGob, ptrINDI )
table.insert( tblSrcGob, ptrSrcGob:Clone() ) -- Save Fix
fhSetValueasLink(ptrSrcGob, ptrINDI)<<<<<<<<<
ptrSrcGob:MoveNext("SAME_TAG")
end

well the fhsetvalueaslink blows it up, and it doesnt really do what I want, I dont think. its a special vocab thing I am dealing with.
but I need to fhCreateItem(ptrSrcGob,ptrINDI) or something there don't I?

wait. do I have to StringTag the pointer to the source gob as INDI.SOUR then copy as text from the pointer
create the item and then set it as link?
oh, this is gruesome. I am miming but not understanding.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28435
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Plugin Help

Post by tatewise »

Sorry, in my original suggestion I used:
CopyChildBranch( ptrSrcGob, ptrINDI )

But later it morphed into:
CopyChildren_FromTo( ptrSrcGob, ptrINDI )

i.e. Replace CopyChildren_FromTo with CopyChildBranch and all will be OK.

Do not use fhSetValueasLink(ptrSrcGob, ptrINDI)

The point is CopyChildren_FromTo only copies the child fields from ptrSrcGob but NOT the Source itself.

Whereas CopyChildBranch first copies the ptrSrcGob Source and then all its children.
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: Plugin Help

Post by Ron Melby »

Thanks, that did it.
FH V.6.2.7 Win 10 64 bit
Post Reply