Can't find commodity using gnc_commodity_table_lookup()

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


Hi,

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
(http://article.gmane.org/gmane.comp.gnome.apps.gnucash.user/25065/match=historical+prices+bond).
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:

  %make 
  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.

Thanks,
	—Justin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: historical.c
Type: text/x-csrc
Size: 1596 bytes
Desc: not available
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20081109/5414f131/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.gnucash
Type: application/octet-stream
Size: 1738 bytes
Desc: not available
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20081109/5414f131/attachment.obj 


More information about the gnucash-devel mailing list