Dynamically adding reports

Derek Atkins warlord at MIT.EDU
Mon Jun 15 10:18:30 EDT 2009

With the templates I was kinda hoping that the user could supply their
own template file in the report options..  So that the base report would
have a default template but allow the user to specify a different
template file..

Note that I haven't looked at the current implementation...


Chris Dennis <cgdennis at btinternet.com> writes:

> Is the following any help?  It's a function I came up with to allow
> eguile-based reports to find their corresponding template file, but in
> fact it's not that specific -- it will look for any file in ~/.gnucash
> or <any-dir-in-the-search-path>/gnucash/report.  It could easily be
> adapted or made more general-purpose.
>  (define (find-template fname)
>    ;; Find the eguile template file 'fname', and return its full path.
>    ;; First look in the user's .gnucash directory.
>    ;; Then look in Gnucash's standard report directory.
>    ;; This is complicated because of the need to cater for
>    ;; various operating systems; so it takes a fairly heuristic,
>    ;; 'best guess' approach.
>    ;; If no file is found, returns just 'fname' for use in error
>    ;; messages.
>    ;; Note: this has been tested on Linux and Windows Vista so far...
>    (let* ((userdir (sub-vicinity (user-vicinity) ".gnucash"))
>           (sysdir  (sub-vicinity (sub-vicinity (user-vicinity)
>                                              "gnucash") "report"))
>           (home (or (home-vicinity)
>                     (getenv "USERPROFILE")
>                     (user-vicinity)
>                     "")))
>      ; make sure there's a trailing delimiter
>      (set! home (sub-vicinity (user-vicinity) home))
>      (let ((home-template (in-vicinity
>                (in-vicinity home userdir) fname)))
>        (if (access? home-template R_OK)
>          home-template
>          (or (%search-load-path (in-vicinity sysdir fname))
>              fname)))))
> cheers
> Chris

       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-devel mailing list