mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-12-02 05:29:20 -06:00
clean up the demos
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1482 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
d199bd73cf
commit
5ffcc53ed2
26
src/swig/examples/scan-acct.pl
Executable file
26
src/swig/examples/scan-acct.pl
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# gnucash perl demo:
|
||||
#
|
||||
# This file demonstrates how to open an acount file and print
|
||||
# the names and balances of the top-level accounts in the file.
|
||||
#
|
||||
# use lib '../swig/perl5/';
|
||||
use lib '../perl5/';
|
||||
use gnucash;
|
||||
package gnucash;
|
||||
|
||||
die "Usage: $0 <filename>" if $#ARGV < 0;
|
||||
print "its $ARGV[0]\n";
|
||||
|
||||
$grp = gnucash::xaccReadAccountGroup ($ARGV[0]);
|
||||
$numacc = gnucash::xaccGroupGetNumAccounts ($grp);
|
||||
print "Loaded $numacc accounts\n\n";
|
||||
|
||||
for ($i=0; $i<$numacc; $i++) {
|
||||
$acct = gnucash::xaccGroupGetAccount ($grp, $i);
|
||||
$acctname = gnucash::xaccAccountGetName ($acct);
|
||||
$baln = gnucash::xaccAccountGetBalance ($acct);
|
||||
print "\tAccount: $acctname \tBalance: $baln\n";
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
(define (list-accts filename)
|
||||
(let ((db (xaccReadAccountGroup filename)))
|
||||
(do ((total (xaccGetNumAccounts db))
|
||||
(do ((total (xaccGroupGetNumAccounts db))
|
||||
(i 0 (+ i 1)))
|
||||
((= i total))
|
||||
(let ((acct (xaccGetAccountFromID db i)))
|
||||
(let ((acct (xaccGroupGetAccount db i)))
|
||||
(write (xaccAccountGetName acct))))))
|
||||
|
Loading…
Reference in New Issue
Block a user