gnucash-devel at andrew.pimlott.net
Sat Mar 22 15:59:21 CST 2003
[Sorry for late reply.]
On Thu, Mar 06, 2003 at 12:23:49PM -0500, Derek Atkins wrote:
> Andrew Pimlott <gnucash-devel at andrew.pimlott.net> writes:
> > Derek Atkins wrote:
> > > Then by all means, use scheme. Using scheme should be REALLY easy
> > > with the 1.8 codebase -- in fact even "gnucash" is a scheme program!
> > (But it seems to use an API that is geared towards "get the GUI
> > running", so that part isn't very useful to me.)
> Uh, gw-engine-spec.scm is CERTAINLY not a "get the GUI running" API.
I was talking about gw-app-file-spec.scm, which is what main.scm
mostly uses. gw-app-file-spec.scm is not implemented on
gw-engine-spec.scm, but rather on C code that is tied to the GUI.
My point was that the fact that gnucash is a scheme program is not
evidence that the scheme API is is well-suited to writing programs
that are independent of the GUI.
> > I'll collect some of the problems I had in another posting.
I've got a test script that can open a book and print the
transactions. I tried to use a date filter to get queries
within a date range.
(define query (gnc:malloc-query))
#t 1 1 2002
#f 1 1 2002
This gives the nonsensical error
<unnamed port>:6:1: In procedure gh_scm2newsymbol in expression (gnc:query-add-date-match query #t ...):
<unnamed port>:6:1: Wrong type argument in position 3: (#@quote query-and)
(The wrapper in gw-engine-spec has the arguments in year-month-day
order instead of day-month-year, but otherwise I have verified that
everything matches up.)
This is in fact different from the error it gave me with a version
of gnucash from a few weeks ago:
ERROR: In procedure gw:enum-<gnc:query-op>-val->int in expression (gnc:query-add-date-match query #t ...):
ERROR: Wrong type argument in position 3: (#<compiled-closure #<primitive-procedure eval-closure>>)
So perhaps there is some memory corruption somewhere?
I tried switching to
(gnc:query-add-date-match-timepair query #t (gnc:get-start-prev-month)
This function appears to work, but there is another problem. All of
the Scheme functions for manipulating timepairs are in in the
app-utils module. When I have load the app-utils module, I get many
warnings when I load a session.
** CRITICAL **: file gnc-component-manager.c: line 271 (gnc_cm_event_handler): assertion `id_type' failed.
An example is at the bottom.
The problem is that when app-utils is loaded, it registers a
callback with gnc_engine_register_event_handler
(gnc-component-manager.c:310). The callback calls
gnc_get_current_book (gnc-component-manager.c:270), which evidently
assumes a GUI context. Basically, gnc_get_current_book looks for
the current session, which finds that there is no current session
(even though I have already created a session), decides to create
one, and then is surprised that it can't find the accounts I am
loading in that session.
I could probably get by loading date-utilities.scm directly (without
app-utils), or by copy-n-pasting the relevant timepair code; but I'm
afraid there will be further problems ahead. These are two examples
of why I am discouraged from using the Scheme API to write my own
I am using CVS that I just updated today. I have guile 1.6, gwrap
1.3.4, and most everything else is from Debian testing.
exec $HOME/local/gnucash/bin/gnucash-env guile -s $0 "$@"
(use-modules (gnucash gnc-module))
(gnc:module-load "gnucash/engine" 0)
(gnc:module-load "gnucash/app-utils" 0)
(define session (gnc:url->loaded-session
"/home/pimlott/pim/gnucash/data" nil nil))
More information about the gnucash-devel