From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Brand Subject: Re: Computations on properties Date: Thu, 10 Oct 2013 11:04:35 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=089e0122814876bdc104e85f4a86 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUCAk-0008G9-PK for emacs-orgmode@gnu.org; Thu, 10 Oct 2013 05:04:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUCAf-0001xp-5x for emacs-orgmode@gnu.org; Thu, 10 Oct 2013 05:04:42 -0400 Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]:36821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUCAe-0001xV-PP for emacs-orgmode@gnu.org; Thu, 10 Oct 2013 05:04:37 -0400 Received: by mail-lb0-f175.google.com with SMTP id y6so1842054lbh.34 for ; Thu, 10 Oct 2013 02:04:35 -0700 (PDT) In-Reply-To: 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: =?ISO-8859-1?Q?Thierry_Pell=E9?= Cc: Org Mode , Eric Schulte --089e0122814876bdc104e85f4a86 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Thierry On Thu, Oct 10, 2013 at 8:39 AM, Thierry Pell=E9 wrote: > After some tests : > =3D=3D> the idea of Michael >> -------------------------------- >> * Mean Calculation >> :PROPERTIES: >> :VAL1: 5 >> :VAL2: 10 >> :COEF: 10 >> :END: >> >> Mean Calculation =3D call_mean() =3D5.454545454545454=3D >> >> * code :noexport: >> #+NAME: mean >> #+HEADER: :var val1=3D'nil >> #+HEADER: :var val2=3D'nil >> #+HEADER: :var coef=3D'nil >> #+BEGIN_SRC emacs-lisp :exports none >> (setq >> val1 (string-to-number (org-entry-get >> org-babel-current-src-block-location "VAL1"= t)) >> val2 (string-to-number (org-entry-get >> org-babel-current-src-block-location "VAL2"= t)) >> coef (string-to-number (org-entry-get >> org-babel-current-src-block-location "COEF"= t))) >> (/ (+ (* val1 coef) val2) (+ coef 1.0)) >> #+END_SRC >> -------------------------------- > > give an error ( "Symbol's value as variable is void: > org-babel-current-src-block-location") This I would expect from an org-version older than 8.1. Check C-h v org-babel-current-src-block-location M-x org-version But if you did not change the version there might be some problem before the first loading of ob-core.el. If you can reproduce it, maybe with a fresh started Emacs, I hope that someone more familiar with autoload etc. than me can help. > =3D=3D> After some tests, it works in changing the "setq" part as > val1 (or val1 (string-to-number > (org-entry-get org-babel-current-src-block-location "VAL1" t) > )) This does still not deal with all cases. As you seem to dive deeper please forget my simplified version posted earlier and see testing/examples/babel.org. > I can't figure out why... See the attached patch that adds comments to testing/examples/babel.org for the two "or" and more. CCed Eric Schulte who I would like to ask to review and apply the patch. > =3D=3D> I will try with python... Start from the shell example in testing/examples/babel.org Did you check if you need the t or nil for org-entry-get? Michael --089e0122814876bdc104e85f4a86 Content-Type: text/plain; charset=US-ASCII; name="0001-Babel-add-comments-to-ERT-for-reading-properties.patch.txt" Content-Disposition: attachment; filename="0001-Babel-add-comments-to-ERT-for-reading-properties.patch.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hmlreq1t0 RnJvbSAwYjdjYWY2YWRmY2FiMWE2YWQyYjFhYTMzMGU3YmQxNWMzYmUzM2QzIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBNaWNoYWVsIEJyYW5kIDxtaWNoYWVsLmNoLmJyYW5kQGdtYWls LmNvbT4KRGF0ZTogVGh1LCAxMCBPY3QgMjAxMyAxMTowMjoxOSArMDIwMApTdWJqZWN0OiBbUEFU Q0hdIEJhYmVsOiBhZGQgY29tbWVudHMgdG8gR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GlvbiAiYiIgdCkgIjAiKQpA QCAtNDMzLDYgKzQzNiwxMSBAQCBOb3RlOiBKdXN0IGV4cG9ydCBvZiBhIHByb3BlcnR5IGNhbiBi ZSBkb25lIHdpdGggYSBtYWNybzoge3t7cHJvcGVydHkoYSl9fX0uCiAjK0hFQURFUjogOnZhciBl PSduaWwKICMrQkVHSU5fU1JDIGVtYWNzLWxpc3AgOmV4cG9ydHMgcmVzdWx0cwogICAoc2V0cQor ICAgOzsgLSBUaGUgZmlyc3QgYG9yJyB0b2dldGhlciB3aXRoICI6dmFyIDx2YXI+PSduaWwnIGlz IHRvIGNoZWNrIGZvcgorICAgOzsgICBhIHZhbHVlIGJvdW5kIGZyb20gYW4gb3B0aW9uYWwgY2Fs bCBhcmd1bWVudCwgaW4gdGhlIGV4YW1wbGVzCisgICA7OyAgIGhlcmU6IGM9NSwgZT02CisgICA7 OyAtIFRoZSBzZWNvbmQgYG9yJyBpcyB0byBkZWFsIHdpdGggYSBwcm9wZXJ0eSBub3QgcHJlc2Vu dAorICAgOzsgLSBUaGUgdCBpcyB0byBnZXQgcHJvcGVydHkgaW5oZXJpdGFuY2UKICAgIGEgKG9y IGEgKHN0cmluZy10by1udW1iZXIKICAgICAgICAgICAgIChvciAob3JnLWVudHJ5LWdldCBvcmct YmFiZWwtY3VycmVudC1zcmMtYmxvY2stbG9jYXRpb24gImEiIHQpCiAgICAgICAgICAgICAgICAg IjAiKSkpCi0tIAoxLjcuMTIuNCAoQXBwbGUgR2l0LTM3KQoK --089e0122814876bdc104e85f4a86--