Just as thought I was getting the hang of the add(), get_value(),  and the
other get_ functions.  I ran into trouble with $i->getvalue("fams");

 

Below is my test GEDCOM file.  I was experimenting with the FAMS and FAMC
tags.  I don't understand why this code fails to find the child to family
link (FAMC) or  the spouse to family link (FAMS), yet $MasterGedCom->write()
writes out the FAMC and FAMS links properly.  What am I missing here?

 

This code:

#!/usr/bin/perl

use strict;

 

use Gedcom;

 

#Read in the GEDCOM file we have so far.

my $MasterGedCom = Gedcom->new(<<Filename of the GECom File containing the
data below>>);

$MasterGedCom->validate();

 

if (defined $MasterGedCom->get_individual("Washburn"))

{

  my @Individuals = $MasterGedCom->get_individual("Washburn");

  my $NumIndividuals = @Individuals;

  print "NumIndividuals = $NumIndividuals.\n";

 

  my %Families = ();

  my $FamilyID;

  my @FamilyTypes = ("famc", "fams");

  my $FamilyType;

  my $Individual;

  foreach $Individual (@Individuals)

  {

    foreach $FamilyType (@FamilyTypes)

    {

      $FamilyType = uc $FamilyType;

      if (defined $Individual->get_value($FamilyType))      # trouble in
paradise begins here

      {

        $FamilyID = $Individual->get_value($FamilyType);

        print  $Individual->get_value("name") . " [$Individual->{xref}] is
part of $FamilyID [$FamilyType].\n";

 

        my @CurrInds = defined $Families{$FamilyID} ? $Families{$FamilyID} :
();

        @CurrInds = push @CurrInds, $Individual->{xref};

        $Families{$FamilyID} = @CurrInds;

      }

      else

      {

        print "Family type, $FamilyType, not defined for " .
$Individual->get_value("name") . " [$Individual->{xref}].\n";

      }

    }

  }

}

else

{

  print "Individual not found\n";

}

 

 

Returned this result:

NumIndividuals = 2.

Family type, FAMC, not defined for John William /Washburn/ [I1].

Family type, FAMS, not defined for John William /Washburn/ [I1].

Family type, FAMC, not defined for William Gordon /Washburn/ [I2].

Family type, FAMS, not defined for William Gordon /Washburn/ [I2].

 

When operating on this GEDCOM file:

0 HEAD

1   SOUR WINTREE

2     VERS 4.81

2     NAME Wintree

1   DEST WINTREE

1   DATE 2 APR 2009

1   SUBM @SUB1@

1   FILE JohnWWashburn.ged

1   GEDC

2     VERS 5.5

2     FORM LINEAGE-LINKED

1   CHAR UTF-8

0 @SUB1@ SUBM

1   NAME John Washburn   

0 @I1@ INDI

1   NAME John William /Washburn/

1   SEX M

1   BIRT

2     DATE 26 AUG 1962

2     PLAC Gurnee, Illinois

1   OCCU Software Tester

1   CHAN

2     DATE 02 APR 2009

3       TIME 16:55:31

1   FAMC @F5@

0 @I2@ INDI

1   NAME William Gordon /Washburn/

1   SEX M

1   BIRT

2     DATE 28 MAR 1941

2     PLAC Gurnee, Illinois (St Therese Hospital in Waukegan)

1   CHAN

2     DATE 04 APR 2009

3       TIME 02:12:34

1   FAMS @F5@

0 @I3@ INDI

1   NAME Barbra Jean /Simcox/

1   SEX F

1   BIRT

2     DATE 1943

2     PLAC Chicago, Illinois

1   CHAN

2     DATE 02 APR 2009

3       TIME 05:04:15

1   FAMS @F5@

0 @F5@ FAM

1   HUSB @I2@

1   WIFE @I3@

1   CHIL @I1@

1   MARR

2     DATE 27 JAN 1962

2     PLAC Waukegan, Illinois

1   CHAN

2     DATE 04 APR 2009

3       TIME 02:13:22

0 TRLR

 

 

Reply via email to