*ITER troubles.

Writing and using plugins for Version 5 and above.
User avatar
Ron Melby
Superstar
Posts: 348
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

ITER troubles.

Postby Ron Melby » 29 Jun 2019 06:15

I know you think this is old ground, sorry. I cannot figure out how to stop an unibounded (or perhaps you might think of them as set within limits) iterator. Never have worked with them on subtypes.

typical FAM record (stripped)

FAM = FAM ptr
HUSBAND = INDI ptr
WIFE = INDI ptr
CHIL = INDI ptr
CHIL = INDI ptr

ANOTHER FAM

here is the stripped code:

local ptr = fhNewItemPtr()
ptr:MoveToFirstRecord('FAM')
while ptr:IsNotNull() do
matFAM(ptr)
...

function matFAM(ptrFAM)
if ptrFAM:IsNotNull() then
...

ptrCHIL = fhGetItemPtr(ptrFAM, '~.CHIL>')
while ptrCHIL:IsNotNull() do
table.insert(tblFAM, fid)
matID(ptrCHIL)
matNAME(ptrCHIL)
matSEX(ptrCHIL)
matLifeInf(ptrCHIL)
matCEM(ptrCHIL)
ptrCHIL:MoveNext('SAME_TAG') -- NEXT Child in FAM
end

it is obvious that CHIL> is an iterator.

I need the ITEM and not LINK for matCEM and that is already a large complex function, I simplistically figure if its an ITEM it is an indi ptr if a link a sour ptr. (although the deciding just between link and item is no small deal.)

of course this will read all CHIL in any fam at present.how can I set limits to this.FAM? Husband and wife work well because they are not in a loop.
FH V.6.2.7 Win 7 64 bit

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

Re: ITER troubles.

Postby tatewise » 29 Jun 2019 08:05

As we discussed before in All in the Family (16887), you are dealing with two data items.
1) The FAM.CHIL tag that is within the Family record
2) The INDI record who is the child, i.e. FAM.CHIL>

So the iteration loop must step through FAM.CHIL[1], FAM.CHIL[2], FAM.CHIL[3], etc.
But the the functions matID(), matNAME(), etc, must operate on each INDI child record.
e.g.

Code: Select all

local ptrCHIL = fhGetItemPtr(ptrFAM, '~.CHIL')   -- No '>' so points to FAM.CHIL[1]
while ptrCHIL:IsNotNull() do
   local ptrINDI = fhGetValueAsLink(ptrCHIL)   -- Get  pointer to child individual
   table.insert(tblFAM, fid)
   matID(ptrINDI)
   matNAME(ptrINDI)
   matSEX(ptrINDI)
   matLifeInf(ptrINDI)
   matCEM(ptrINDI)
   ptrCHIL:MoveNext('SAME_TAG') -- NEXT Child in FAM
end
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Ron Melby
Superstar
Posts: 348
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: ITER troubles.

Postby Ron Melby » 30 Jun 2019 14:54

plain as the face on my head when you say it, dont know why I cant get that to stick in my head, on my face.
FH V.6.2.7 Win 7 64 bit


Return to “Plugin Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests