Can't find commodity using gnc_commodity_table_lookup()

Justin Mazzola Paluska jmp at MIT.EDU
Sun Nov 9 12:04:14 EST 2008


I’m trying to write a small program to add (historical) prices to my
gnucash file.  I’m basing my approach off of some code I found on the
gnucash-users list
Essentially, my code opens up the book, tries to find a commodity
(hard coded to “GOOG” for testing) and then creates a new price for
that commodity.  I’ve attached my code to this message, as well as an
example.gnucash file that I’ve been using.

Unfortunately, I’m getting stuck — even though I’ve defined a GOOG
security in my gnucash file, I can’t seem to retrieve it from my file
using “gnc_commodity_table_lookup()”: I always get NULL for my
commodity, even though I can zless the example.gnucash file and can
see my commodity, as well as edit it in gnucash.

To wit, here’s a transcript of a session with my code:

  gcc -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -I/usr/include/gnucash -L/usr/lib/gnucash -lgnc-core-utils -lgnc-qof -std=c99 -lgnc-backend-file-utils historical.c -g -o historical
  %gnucash-env ./historical
  Has NYSE namespace
  commodity is NULL

(The example.gnucash file is in the same directory as the program.)

Am I doing something wrong?  I’m using gnucash 2.2.6 on Ubuntu 8.10.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: historical.c
Type: text/x-csrc
Size: 1596 bytes
Desc: not available
Url : 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.gnucash
Type: application/octet-stream
Size: 1738 bytes
Desc: not available
Url : 

More information about the gnucash-devel mailing list