*spouse count

Writing and using plugins for Version 5 and above.
Ron Melby
Famous
Posts: 230
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

spouse count

Postby Ron Melby » 01 Jan 2019 15:41

marriage is not important, I am trying to get the plugin I am working on to count for lack of a better term, "get togethers", whether or not there is a known spouse.

lets look at sally:
sally was a spouse to dave, no children not sure if married
sally had a child with unknown person
sally married fred and had some chilrden

I believe that makes 3 FAMS records. I need the count of three.
where there is no "get together" I would expect zero.

I looked around for code and found this:

function for marriage count? (13045)

I made this statement from that in my lua plugin

mc = calc(NumberIf(Exists(%INDI.~FAMS[1]>%),1,0) +
NumberIf(Exists(%INDI.~FAMS[2]>%),1,0) +
NumberIf(Exists(%INDI.~FAMS[3]>%),1,0) +
NumberIf(Exists(%INDI.~FAMS[4]>%),1,0) +
NumberIf(Exists(%INDI.~FAMS[5]>%),1,0) +
NumberIf(Exists(%INDI.~FAMS[6]>%),1,0) )


this is my error.
unexpected symbol near '%'

is this something simple or do I need to do a loop and counts if not null?
Win 7 64 bit. FH V.6.2.6

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

Re: spouse count

Postby tatewise » 01 Jan 2019 16:22

Ron, you're taking an FH Expression intended for a Query (or perhaps Diagram or Report) and using it in a Plugin.
Unfortunately that won't work because the syntax structure is completely different.

In earlier Plugin Discussions you learnt how to use ptrINDI to reference each Individual record in turn.
Also how to loop through instances of subsidiary data such as:

Code: Select all

  local ptrATTR = fhNewItemPtr()
  ptrATTR:MoveTo(ptrINDI,"~._ATTR-MILT")     
  while ptrATTR:IsNotNull() do                      -- Process each Military Attribute

    ptrATTR:MoveNext("SAME_TAG")           -- Move to next Military Attribute
  end
 

Well you must do the same here using "~.FAMS" in place of "~._ATTR-MILT" and count how many times it loops.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Jane
Site Admin
Posts: 7480
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: spouse count

Postby Jane » 02 Jan 2019 09:24

Code: Select all

function countTag(ptrRecord,sTag)
    local ptrATTR = fhNewItemPtr()
    local c = 0
    ptrATTR:MoveTo(ptrRecord,sTag)
    while ptrATTR:IsNotNull() do
        c = c + 1
        ptrATTR:MoveNext("SAME_TAG")
    end
    return c
end

ptrTable = fhGetCurrentRecordSel('INDI')
ptrIndi = ptrTable[1]
if ptrIndi then
    fhMessageBox(fhGetDisplayText(ptrIndi)..
    '\nCount of Family As Spouse: '..countTag(ptrIndi,'~.FAMS')..
    '\nCount of Family As Child: '..countTag(ptrIndi,'~.FAMC')..
    '\nCount of Occupations: '..countTag(ptrIndi,'~.OCCU')
    )
end


The above is a working example, using a reusable function to count the occurrences. You just need a record selected or it won't do anything.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

Ron Melby
Famous
Posts: 230
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: spouse count

Postby Ron Melby » 02 Jan 2019 16:23

Jane and Mike, that is pretty much what I have done, my hangup with tags themselves has been a downfall..

I was trying to do something like:

ptrINDI ,( "~.NAME["..i.."]")

when I actually get to the bottom line, (I am lining up counts now, subtracting one from Female Names for birth names....

is there such a thing as the following

fnwhatever(ptrINDI)

new local table tblMarrNam ( I need it initialized every time right?)
new local table tblHubbyNam (same)
my understanding is it is major to initialize every time and tricky.

read female additional names:Last
read all husband names:Last
compare husband last to female last and blank names as found (ipairs?)

what is left over in husbandtable
if string.gsub("[?") not found in lastname for husband then(ignore unknowns)
add glued up name to wife
end

I am aware FH does this virtually, but due to gedcom "trading partner" concerns I need it done explicitly
Win 7 64 bit. FH V.6.2.6

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

Re: spouse count

Postby tatewise » 02 Jan 2019 16:55

Ron, please start a new thread as this appears to be nothing about spouse counts.

Also you need to describe your objectives in plain English, otherwise we have no idea what you are talking about.
Your pseudo-code makes no sense, because we don't know what you are trying to achieve.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Ron Melby
Famous
Posts: 230
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: spouse count

Postby Ron Melby » 02 Jan 2019 17:22

I thought it had everything to do with spouse counts.

Lets look at Sally Muckenfutch

she had FAMS with the following:

John [?Muckenfutch] (dont know his last name)
Fred Ells
Jake Johnson
Jim Jabez
Sherlock Holmes.

Therefore her NAME "gob" should be
Sally Muckenfutch (birth name)
Sally Ells
Sally Johnson
Sally Jabez
Sally Holmes
Sally [?Muckenfutch] will not be added because it is an unknown name.

The opposite case may be true but the logic no different.
she could be
Sally [?Muckenfutch] (very common the womans maiden name is unknown)
but her husband:
Fred Muckenfuctch would get her spousal name correctly.

(FYI, and not maybe the gravamen of the programming problem), sometimes on FaG, the woman is not buried with the last husband, and the name may be "earlier", it helps to find them.


Count the spouses, count the names, make them 'at least' same as names of known spouses, plus birth names.
Win 7 64 bit. FH V.6.2.6

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

Re: spouse count

Postby tatewise » 02 Jan 2019 18:00

Yes, but what is your fundamental objective?
e.g.
You want a Result Set listing every woman with her maiden surname and each of her partners' surnames, where partner relates to every Family as spouse (FAMS) link, but excluding all cases where the surname is unknown.
A surname is unknown if it does not exist at all or is enclosed in square brackets such as [?Unknown].

To me, that does not involve counting with numbers, but does involve searching for names, which are two rather different tasks.

BTW: You'll have to explain what gob and FaG mean.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Ron Melby
Famous
Posts: 230
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: spouse count

Postby Ron Melby » 02 Jan 2019 18:09

FaG is FindaGrave. gob (as I have used it before here) is a contrived record set.

name[1]
name[2]
name[3]

or as another example
an event with all notes, roles, sources and so on.
which if I went in by hand and deleted any record would UDF or error the entire event.

the gob from 1...n records that make up the whole and ancillary parts of the TAG.

I not only want the result set, but want to post it to the record gob.
Win 7 64 bit. FH V.6.2.6

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

Re: spouse count

Postby tatewise » 02 Jan 2019 18:23

Sorry Ron, I give up. I cannot help you until your objectives are clearly stated.
I have no idea what post it to the record gob means.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Ron Melby
Famous
Posts: 230
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: spouse count

Postby Ron Melby » 02 Jan 2019 19:50

0 @I2204@ INDI
1 NAME Emma Agnes /Gilbertson/
1 NAME Emma Agnes /Gulbranson/
1 NAME Emma /Goldsmith/
<snip>
1 FAMC @F931@
1 FAMS @F849@
1 FAMS @F507@
1 FAMS @F674@
1 FAMS @F447@

SPOU in order as are FAMS
0 @I1714@ INDI
1 NAME William Leslie /Ruston/

0 @I836@ INDI
1 NAME Marlin Judd /Hightower/
1 NAME William /Hightower/

0 @I1188@ INDI
1 NAME Frank /Lindsey/

0 @I734@ INDI
1 NAME Joel Salomon /Goldsmith/


Which should result in this:

0 @I2204@ INDI
1 NAME Emma Agnes /Gilbertson/
1 NAME Emma Agnes /Gulbranson/ --in Norwo-Americans, this is not uncommon.
1 NAME Emma Agnes /Ruston/
1 NAME Emma Agnes /Hightower/ --no additional last names only the first name changed.
1 NAME Emma Agnes /Lindsay/
1 NAME Emma Agnes /Goldsmith/

(LUA comments for clarification of problem statement.)
Win 7 64 bit. FH V.6.2.6

User avatar
Jane
Site Admin
Posts: 7480
Joined: 01 Nov 2002 15:00
Family Historian: V6.2
Location: Somerset, England
Contact:

Re: spouse count

Postby Jane » 03 Jan 2019 08:26

So to confirm you want to permanently write all the married name options to the Individual record for the woman, and thereafter maintain them manually?

Personally I would not do this as it's potentially very confusing if you share your data to have all the married names recorded against the record, you can achieve a search by married name and produce a list of all possible names for a person easily as needed using a result set plugin, similar to the logic for
Search All Possible Names

You could also use that as a base for your plugin.

Remember you will need to build a table of items to add in and process them in outside of the loop.

Similar to the examples in this post
https://www.taubman.org.uk/family/wp/20 ... historian/
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
tatewise
Megastar
Posts: 15425
Joined: 25 May 2010 11:00
Family Historian: V6.2
Location: Torbay, Devon, UK
Contact:

Re: spouse count

Postby tatewise » 03 Jan 2019 11:31

But he also appears to want to keep the existing Primary maiden name, and some Alternate maiden names.
e.g. /Gilbertson/ and /Gulbranson/ in his example, but not /Goldsmith/, presumably because that matches one of the husbands' surnames, but the rules are not entirely clear, and we are certainly NOT talking about counting anything now!
That is why it would be useful to have a clear statement of the objectives in plain words.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry


Return to “Plugin Discussions”

Who is online

Users browsing this forum: No registered users and 4 guests