* Siblings enumerations

Writing and using plugins for Version 5 and above.
Post Reply
User avatar
Talln
Gold
Posts: 18
Joined: 09 Feb 2021 17:15
Family Historian: V7
Location: London

Siblings enumerations

Post by Talln » 15 May 2022 18:17

Hi again

I need to extract a list of children of a family in birth sequence (or as entered) in a Plugin.

I thought this would be straightforward: find the FAM record and work through the CHIL records. Trouble is that (a) not all of the children are being returned (the MoveNext only returns a child with a higher Innnn ref), and (b) my loop keeps going until all subsequent INDI records have been exhausted regardless that they are not CHIL of this FAM.

The data in the GEDCOM is:

Code: Select all

0 @F1551@ FAM
1 MARR
2 DATE 5 OCT 1748
2 PLAC Kimcote,Lutterworth,Leicestershire,England
2 SOUR @S851@
3 DATA
4 TEXT 1748
5 CONT October 5th George Adcock of Burbage & Ann Allen of Walton: Knap.ffee. were married Ban. Pub.  [i.e Walton in Knaptoft] 
3 OBJE @O1999@
4 _SEQ 1
1 HUSB @I5885@
1 WIFE @I5895@
1 CHIL @I5887@
1 CHIL @I2640@
1 CHIL @I5888@
1 CHIL @I5889@
1 CHIL @I5890@
1 CHIL @I5891@
1 CHIL @I5892@
1 CHAN
2 DATE 24 JAN 2022
3 TIME 18:06:48
My code is:

Code: Select all

    local ptrFamily = fhNewItemPtr() 
    ptrFamily:MoveToFirstRecord("FAM") -- set to the first Family record.
	while not ptrFamily:IsNull() do

        iFam = iFam + 1

-- some processing of Husband and Wife here

        -- CHILDREN of family (in correct sequence) This used to populate birth sequence in Individual 
        local ptrChild = fhNewItemPtr() --child
        ptrChild = fhGetItemPtr(ptrFamily,"~.CHIL>")
        i = 0
        while not ptrChild:IsNull() do
            i = i + 1
--DEBUG
            if tblFamily[iFam].familyid == 1551 then
                fhMessageBox('Fam= '..tblFamily[iFam].familyid..' Child='..fhGetRecordId(ptrChild)..' sequence='..i)
                ProgressBar.Message(iFam.." families identified")   
                if ProgressBar.Stop() then return 'Cancelled by user'; end -- if user has cancelled
            end
--DEBUG END
            tblSibSequence[tblFamily[iFam].familyid][fhGetRecordId(ptrChild)] = i
       
            ptrChild:MoveNext("SAME_TAG") -- next Child record

        end
        ptrChild:SetNull()
        ptrFamily:MoveNext("SAME_TAG") -- next Family record
    end
    
What is see is a series of messages for FAM 1551 starting with 5887 then counting up to 6270 (my last INDI record). The record 2640 which is the second eldest child is not listed!

Undoubtedly I'm missing something, but the code is the same as the logic I have for NAMEs which works fine.

Any help warmly appreciated!

Paul
Paul Weaver, London

User avatar
Jane
Site Admin
Posts: 8340
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Siblings enumerations

Post by Jane » 16 May 2022 08:09

What is happening currently is you are moving your ptrChild point to the Individual records and then looping that.

What you need to do is loop the child links in the Family Record.

So define

Code: Select all

  local ptrChildRec = fhNewItemPtr()
then on line 12

Code: Select all

   ptrChild = fhGetItemPtr(ptrFamily,"~.CHIL")
Then around line 16 set your new pointer to the Child's Individual Record

Code: Select all

ptrChildRec:MoveTo(ptrChild,'~>')
.
and use the ptrChildRec to access the childs data.
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
Talln
Gold
Posts: 18
Joined: 09 Feb 2021 17:15
Family Historian: V7
Location: London

Re: Siblings enumerations

Post by Talln » 16 May 2022 22:26

Thanks !
Paul Weaver, London

Post Reply