* spouse count

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.
Post Reply
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

spouse count

Post by Ron Melby »

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?
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28333
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: spouse count

Post by tatewise »

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: 8507
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: spouse count

Post by Jane »

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."
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: spouse count

Post by Ron Melby »

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
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28333
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: spouse count

Post by tatewise »

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
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: spouse count

Post by Ron Melby »

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.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28333
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: spouse count

Post by tatewise »

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
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: spouse count

Post by Ron Melby »

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.
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28333
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: spouse count

Post by tatewise »

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
User avatar
Ron Melby
Megastar
Posts: 917
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: spouse count

Post by Ron Melby »

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.)
FH V.6.2.7 Win 10 64 bit
User avatar
Jane
Site Admin
Posts: 8507
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: spouse count

Post by Jane »

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: 28333
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: spouse count

Post by tatewise »

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
Post Reply