From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: Unit conversions and symbolic mathematics with Babel Date: Wed, 03 Sep 2014 09:19:26 +0200 Message-ID: References: <87vbp5urc4.fsf@vsl28t2g.ww011> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XP4rG-0007UU-Hl for emacs-orgmode@gnu.org; Wed, 03 Sep 2014 03:20:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XP4rA-0002ey-KT for emacs-orgmode@gnu.org; Wed, 03 Sep 2014 03:19:58 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:55299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XP4rA-0002dE-EQ for emacs-orgmode@gnu.org; Wed, 03 Sep 2014 03:19:52 -0400 In-Reply-To: <87vbp5urc4.fsf@vsl28t2g.ww011> (H. Dieter Wilhelm's message of "Wed, 03 Sep 2014 08:54:19 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "H. Dieter Wilhelm" Cc: Jay Belanger , emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On 2014-09-03 08:54, dieter@duenenhof-wilhelm.de (H. Dieter Wilhelm) writes: > But what is missing is to assign variables within a source block >=20=20=20 > > #+BEGIN_SRC calc :var L1 =3D "5 mm"=20 > L2 :=3D cvun( L1, m) > #+END_SRC=20=20=20=20 > >=20=20=20 > Unfortunately this is not working. Do you have an idea how to > implement this? It seems that you could use block chaining. Here is an extract of some code I use to compute stats for my book keeping: #+name: monthly_average #+begin_src emacs-lisp :var starty=3D2014 :var startm=3D3 :var amount=3D100= =20 (let* ((tm (decode-time)) (cmonth (nth 4 tm)) (cyear (nth 5 tm)) (nbmonths (+ (* 12 (- cyear starty)) (- cmonth startm)))) (calc-eval "round($ / $$, 2)" nil amount nbmonths)) #+end_src #+name: ledger_average #+begin_src emacs-lisp :var b=3D"Quotidien" :var sy=3D2014 :var sm=3D3 :va= r sd=3D"2014-03-01" :var p=3D"Expenses:" (let* ((per (format "from %d-%d-01 to this month" sy sm)) (a (org-sbe call_ledger (bucket (eval b)) (prefix (eval p)) (perio= d (eval per))))) (org-sbe monthly_average (amount (eval a)) (starty (eval sy)) (startm (= eval sm)))) #+end_src The last line of the second block calls the first block to do its computation. The first block does not have to be in emacs-lisp, but I don't know calc well enough to do it directly in calc. Best, Alan =2D-=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBCgAGBQJUBsEWAAoJEAQNCjtO0uXHiSEH/2gViWLcS/Jl5E85StjAbieG jXGQsmcSkNtNEcxFyFXggHC3f6RRzdyuKEiO4pcuPENElXHd+14plC4mcJSTZ1Fi +O+Dk4KN49iu7eRtlOo32ppa5jTAxjo1IgW2ynnOKD0+ztgDiJMysKpvmzwqn5Ju Avz323Z2q6TnOtAV1fFOepBQZ6Z3NF82lx4gUaZwaYduEsLrjjgTnCJTLxZMS3Xp syHtW0VfuBDRc2gb8tRPAVu9En3kOahko+mrlMg/XwI3fVRYvmn5TVMAGWe59RWk 3fB/5Ux6MUFRJtTjirZ/H4f0peDyEFn2Klmj8R5FfxT6TC/u4EArlPSPhexOwgY= =evFr -----END PGP SIGNATURE----- --=-=-=--