emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Brett Witty <brettwitty@brettwitty.net>
Cc: Org mailing list <emacs-orgmode@gnu.org>
Subject: Re: Large numbers of named variables in Babel
Date: Wed, 06 Aug 2014 11:15:03 -0400	[thread overview]
Message-ID: <8561i5r6o8.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <CANK_Tn-JrqP9XvKGCvDjuGR_qJjEAAWjtHooGEYAkRqb8BTHEg@mail.gmail.com> (Brett Witty's message of "Thu, 7 Aug 2014 00:27:09 +1000")

Brett Witty <brettwitty@brettwitty.net> 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	other threads:[~2014-08-06 15:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-06 14:27 Large numbers of named variables in Babel Brett Witty
2014-08-06 15:15 ` John Kitchin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8561i5r6o8.fsf@andrew.cmu.edu \
    --to=jkitchin@andrew.cmu.edu \
    --cc=brettwitty@brettwitty.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).