Report development without the need to restart GnuCash
Derek Atkins
warlord at MIT.EDU
Thu May 22 14:42:11 EDT 2008
Hi,
There's an example of a menu item to reload a report. If you look at
src/business/business-gnome/gnc-plugin-business.c you'll notice
a menu item that winds up calling gnc_plugin_business_reload_module()
which then calls out to scheme gnc:reload-module...
-derek
Quoting Torsten Edeler <torsten at edeler.org>:
> Hi everybody.
>
> I'm quite new to GnuCash. Recently I felt the need to make my own report
> adapted to my needs, since the existing reports were not suitable. After
> taking a look to this obscure language Scheme - which I will probably never
> like :-) - the question rised how to develop reports without having the need
> to restart the whole application after a little bit of the report had to be
> changed. I searched the mailing list, but hadn't found anything usefull.
>
> I would like to present my solution to that problem to you. Perhaps it has
> already been solved (probably more elegant) by some of you or I missed it in
> the ml. Anyway this is what I use at the moment for development.
>
> I have the report file which is load by GnuCash on Startup:
>
> (define pagename-general "General")
> (define (options-generator)
> (load "/home/torsten/.gnucash/reports/myoptions.scm")
> (myoptions)
> )
>
>
> (define (renderer options)
> (load "/home/torsten/.gnucash/reports/renderer.scm")
> (myrenderer options)
> )
>
>
> (let ()
> (gnc:define-report
> 'version 1
> 'name (N_ "Trivial Example")
> 'options-generator options-generator
> 'renderer renderer)
> )
>
> As you can see the renderer and the options-generator include a file load.
> So everytime GnuCash executes one of the functions, a fresh version of the
> file is loaded and executet. The files itself defines a function "myoption"
> and "myrenderer" respectively. Note that the option-generator is only
> executed after loading the report from the menu (or on startup), whereas the
> renderer is also executet after reloading or modification of the options.
>
> Unfortunatly GnuCash is very sensible to errors in the option-generator,
> since it simple terminates the whole application. The renderer behaves more
> nicely: Only an error message is displayed in the report window and one has
> the chance to modify the file and reload the report.
>
>
> I hope this little texts helps some of you. At least it would have helped me
> :-)
>
> regards,
> Torsten
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.
>
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord at MIT.EDU PGP key available
More information about the gnucash-user
mailing list