From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Large numbers of named variables in Babel Date: Wed, 06 Aug 2014 11:15:03 -0400 Message-ID: <8561i5r6o8.fsf@andrew.cmu.edu> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XF2uw-0001es-9Z for emacs-orgmode@gnu.org; Wed, 06 Aug 2014 11:14:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XF2ur-000147-Gt for emacs-orgmode@gnu.org; Wed, 06 Aug 2014 11:14:18 -0400 Received: from mail-qg0-x234.google.com ([2607:f8b0:400d:c04::234]:33660) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XF2ur-000143-Cg for emacs-orgmode@gnu.org; Wed, 06 Aug 2014 11:14:13 -0400 Received: by mail-qg0-f52.google.com with SMTP id f51so2868379qge.11 for ; Wed, 06 Aug 2014 08:14:12 -0700 (PDT) In-Reply-To: (Brett Witty's message of "Thu, 7 Aug 2014 00:27:09 +1000") 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: Brett Witty Cc: Org mailing list Brett Witty 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