Re: program with gedcom.pm help

[email protected] (Nate Fuhriman)
Newsgroups perl.gedcom
Message-ID <[email protected]>
sorry i forgot to mention one thing. when i'm in a source and try to
add an object with file/form. i get the following error
FORM is not a sub-item of OBJE
FILE is not a sub-item of OBJE

here is essentially the code i'm running
$ged = Gedcom->new(grammar_version => 5.5 );
$record=$ged->add_source();
$obje=$record->add("obje");
$obje->add("form", "png");
$obje->add("file", "somefile");

thanks for any additional advice.
nate

On 1/23/06, Paul Johnson <[email protected]> wrote:
> On Thu, Jan 12, 2006 at 06:15:17PM -0700, Nate Fuhriman wrote:
>
> > I am using gedcom.pm to create a simple gedcom editing program. it's
> > basically a thin layer to allow a user access to gedcom files. I am having
> some
> > problems though and was wondering if anybody out there could help.
>
> Looks like that'll be me then ;-)
>
> > how do I automatically find out if I can have multiple items. IE I can
> have
> > many FAMS tags but only one SEX tag. I have tried using $record->max but
> > that always fails as an invalid call.
>
> Yes.  You'll need to get into the actual grammar object to get this
> information.  I don't have a proper API to this, so there is a
> possibility that things might change, but something like the following
> should give you the information you want:
>
>     $record->{grammar}->valid_items->{$tag}[0]{min}
>     $record->{grammar}->valid_items->{$tag}[0]{max}
>
> Here, $record is the parent record, and $tag the name of the tag you are
> interested in.  For example:
>
>     my $i = $ged->get_individual("I8");
>     print $i->{grammar}->valid_items->{NAME}[0]{max};
>     print $i->{grammar}->valid_items->{SEX}[0]{max};
>
> The call to $i->{grammar}->valid_items returns a hash reference, the
> keys of which are the names of all the valid items for that record.  The
> values are arrays of hashes, each hash containing the grammar, the min
> and the max.  There is an array of hashes because the same tag can refer
> to more than one grammar.  This is the case with NOTEs for example,
> which can either be inline or can point to a note record.  It is safe
> (at the moment) to just look at the first record since where there are
> multiple records, the min and max are always the same.  The docs (and
> maybe even the source) to Gedcom::Grammar may shed a little light on
> this.
>
> > how do I properly link external documents to SOUR. I have a gedcom file
> that
> > was created with PAF that shows
> > 1   OBJE hello
> > 2     FORM png
> > 2     FILE page1.png
> > 2     NOTE some description
> > but gedcom.pm says that form, file and note are not valid tags for obje.
> is
> > there a different way? sample code maybe?
>
> I'm afraid you'll need to be a little more explicit in describing this,
> or better still send some minimal GEDCOM file, since it "works for me".
>
> Here's the GEDCOM file I tested it with.  This was created by Gedcom.pm
> and I just added your four lines.
>
> 0 HEAD
> 1   SOUR Gedcom.pm
> 2     NAME Gedcom.pm
> 2     VERS 1.1502
> 2     CORP Paul Johnson
> 3       ADDR http://www.pjcj.net
> 2     DATA
> 3       COPR Copyright 1998-2005, Paul Johnson ([email protected])
> 1   NOTE
> 2     CONT This output was generated by Gedcom.pm.
> 2     CONT Gedcom.pm is Copyright 1999-2005, Paul Johnson ([email protected])
> 2     CONT Version 1.1502 - 20th December 2005
> 2     CONT
> 2     CONT Gedcom.pm is free.  It is licensed under the same terms as Perl
> itself.
> 2     CONT
> 2     CONT The latest version of Gedcom.pm should be available from my
> homepage:
> 2     CONT http://www.pjcj.net
> 1   GEDC
> 2     VERS 5.5
> 2     FORM LINEAGE-LINKED
> 1   DATE Mon Jan 23 12:31:25 2006
> 1   CHAR ANSEL
> 1   SUBM @SUBM1@
>
> 0 @SUBM1@ SUBM
> 1   NAME Paul Johnson
> 1   OBJE hello
> 2     FORM png
> 2     FILE page1.png
> 2     NOTE some description
>
> 0 TRLR
>
> > how do I setup the CONT tag? if I add a note it just goes on a single
> line.
>
> Take a look at the code in Gedcom::new, which creates the GEDCOM file
> above.  Basically, you just add CONT records to a NOTE record.
>
> > This probably leads to another point of confusion I have. It looks like
> some
> > tags (NOTE,PLAC) allow data to be put to them and have sub tags. is there
> a
> > way to automatically recognize this?
>
> Yes.  This is a pain, I think, since it means that I need to have
> separate methods to return the value associated with a tag or the
> record.
>
> Again, I don't have a proper API for this, but the information is
> available.  (And I have just noticed that I don't give any warning if a
> value is provided where none is expected.)  You can access the
> information so:
>
>     my $i = $ged->get_individual("I1");
>     print "NOTE  [", exists $i->get_record("note")->{grammar}{value}, "]\n";
>     print "BIRT  [", exists $i->get_record("birt")->{grammar}{value}, "]\n";
>
> If the "value" key is present in the grammar, then a value is allowed,
> otherwise it is not.
>
> > Thanks in advance.
> > Nate
> >
> > FYI once I have the program working I'm more than happy to share. :)
>
> I look forward to it.  Sorry for the delayed reply.
>
> --
> Paul Johnson - [email protected]
> http://www.pjcj.net
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.