emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Computations on properties


From: Michael Brand
Subject: Re: [O] Computations on properties
Date: Wed, 9 Oct 2013 21:27:45 +0200

Hi Thierry

On Wed, Oct 9, 2013 at 2:19 PM, Thierry Pellé <address@hidden> wrote:
> Mean Calculation=RES (where RES is the value of the result)

One more variant would be to use inline source block calls either
interactively with C-c C-c or during export. An example with shell
(python would be very similar) or the built-in Emacs Lisp is in the
Emacs Regression Test ERT in the top heading "use case of reading
entry properties" here:
http://orgmode.org/w/?p=org-mode.git;a=blob;f=testing/examples/babel.org

Your use case, here with Emacs Lisp, would be e. g.:

--------------------------------
* Mean Calculation
  :PROPERTIES:
  :VAL1:     5
  :VAL2:     10
  :COEF:     10
  :END:

  Mean Calculation = call_mean() =5.454545454545454=

* code :noexport:
  #+NAME: mean
  #+HEADER: :var val1='nil
  #+HEADER: :var val2='nil
  #+HEADER: :var coef='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
--------------------------------

Michael



reply via email to

[Prev in Thread] Current Thread [Next in Thread]