emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Large numbers of named variables in Babel


From: John Kitchin
Subject: Re: [O] Large numbers of named variables in Babel
Date: Wed, 06 Aug 2014 11:15:03 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (windows-nt)

Brett Witty <address@hidden> writes:

This is close to what you want I think.

#+TBLNAME: stats
| STR | 13 |
| DEX | 12 |
| CON | 11 |


#+BEGIN_SRC python :results value :var data=stats
d = dict(data)
return d['DEX'] + d['CON']
#+END_SRC

#+RESULTS:
: 23


> Hi,
>
> I'm trying to write my RPG adventures in org-mode and would like to
> bring character sheets into that fold. Is there a way in Babel to have
> a vast number of named variables that I can feed into source blocks?
> Are macros the way to achieve this?
>
> As an example, I'd like something like a big (hidden) table:
> #+NAME: stats
> | STR | 13 |
> | DEX | 12 |
> | CON | 11 |
>
> and then later I can use that like:
> #+NAME: AC
> #+begin_src python :var dex=table[DEX] :var armour=table[ARMOUR]
> return dex + armour
> #+end_src
>
> I know I can make explicit cell references, but it'd be neat to just
> use keys for values.
>
> Cheers,
>
> BrettW
>

-- 
-----------------------------------
John Kitchin
Professor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.edu



reply via email to

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