emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Why doesn't this calc org-babel code work?
@ 2012-05-24 22:51 Christopher Allan Webber
  2012-05-24 22:56 ` Christopher Allan Webber
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Allan Webber @ 2012-05-24 22:51 UTC (permalink / raw)
  To: emacs-orgmode

Hey all...

I have:

#+BEGIN_SRC calc
foo := 5
foo + 5 =>
#+END_SRC

#+RESULTS:
: foo + 5 => foo + 5

What I'd like, obviously, is for it to result in:

#+RESULTS:
: foo + 5 => 10

I guess I really don't understand how calc support works in org-babel.
Could someone enlighten me?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why doesn't this calc org-babel code work?
  2012-05-24 22:51 Why doesn't this calc org-babel code work? Christopher Allan Webber
@ 2012-05-24 22:56 ` Christopher Allan Webber
  2012-05-24 23:02   ` Christopher Allan Webber
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Allan Webber @ 2012-05-24 22:56 UTC (permalink / raw)
  To: emacs-orgmode

I see now.

#+BEGIN_SRC calc :var foo=5
foo + 5 =>
#+END_SRC

#+RESULTS:
: 5 + 5 => 10

However, this isn't as useful as I'd like.  I'd really like to be able
to see it say "foo + 5 =>" in the output.  That's clearer which line is
being referred to...

Christopher Allan Webber <cwebber@dustycloud.org> writes:

> Hey all...
>
> I have:
>
> #+BEGIN_SRC calc
> foo := 5
> foo + 5 =>
> #+END_SRC
>
> #+RESULTS:
> : foo + 5 => foo + 5
>
> What I'd like, obviously, is for it to result in:
>
> #+RESULTS:
> : foo + 5 => 10
>
> I guess I really don't understand how calc support works in org-babel.
> Could someone enlighten me?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why doesn't this calc org-babel code work?
  2012-05-24 22:56 ` Christopher Allan Webber
@ 2012-05-24 23:02   ` Christopher Allan Webber
  2012-05-28 16:35     ` Eric Schulte
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Allan Webber @ 2012-05-24 23:02 UTC (permalink / raw)
  To: emacs-orgmode

I guess what I'm saying is that assignment would be really nice.
However, I'm now seeing that this would take a lot of work.

What I'd really like to do is something like the following:

# Total BS financial projection, don't read into this at all
#+BEGIN_SRC calc
derp_expenses := 1234
derp_income := 4315

monthly_balance := derp_income - derp_expenses
monthly_balance =>
monthly_balance * 12 =>
#+END_SRC

#+RESULTS:
: monthly_balance => 3081
: monthly_balance * 12 => 36972

I guess I could use calc embedded mode, but I haven't figured out how to
do that yet. ;)

 - Chris

Christopher Allan Webber <cwebber@dustycloud.org> writes:

> I see now.
>
> #+BEGIN_SRC calc :var foo=5
> foo + 5 =>
> #+END_SRC
>
> #+RESULTS:
> : 5 + 5 => 10
>
> However, this isn't as useful as I'd like.  I'd really like to be able
> to see it say "foo + 5 =>" in the output.  That's clearer which line is
> being referred to...
>
> Christopher Allan Webber <cwebber@dustycloud.org> writes:
>
>> Hey all...
>>
>> I have:
>>
>> #+BEGIN_SRC calc
>> foo := 5
>> foo + 5 =>
>> #+END_SRC
>>
>> #+RESULTS:
>> : foo + 5 => foo + 5
>>
>> What I'd like, obviously, is for it to result in:
>>
>> #+RESULTS:
>> : foo + 5 => 10
>>
>> I guess I really don't understand how calc support works in org-babel.
>> Could someone enlighten me?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why doesn't this calc org-babel code work?
  2012-05-24 23:02   ` Christopher Allan Webber
@ 2012-05-28 16:35     ` Eric Schulte
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Schulte @ 2012-05-28 16:35 UTC (permalink / raw)
  To: Christopher Allan Webber; +Cc: emacs-orgmode

Christopher Allan Webber <cwebber@dustycloud.org> writes:

> I guess what I'm saying is that assignment would be really nice.
> However, I'm now seeing that this would take a lot of work.
>
> What I'd really like to do is something like the following:
>
> # Total BS financial projection, don't read into this at all
> #+BEGIN_SRC calc
> derp_expenses := 1234
> derp_income := 4315
>
> monthly_balance := derp_income - derp_expenses
> monthly_balance =>
> monthly_balance * 12 =>
> #+END_SRC
>
> #+RESULTS:
> : monthly_balance => 3081
> : monthly_balance * 12 => 36972
>
> I guess I could use calc embedded mode, but I haven't figured out how to
> do that yet. ;)
>

Using variable names without underscores will get you closer to the
functionality you are after as in the following.

#+BEGIN_SRC calc :var expenses=1234 :var income=4321
  12*(income-expenses)
#+END_SRC

#+RESULTS:
: 37044

However, code blocks are used more like regular stack calc mode as in
the following example.

#+begin_src calc
24
3
'/
#+end_src

#+RESULTS:
: 8

If you'd rather write something looking more like your example, I'd
recommend either using any programming language with nice simple syntax,
e.g.,

#+BEGIN_SRC python :var derp_expenses=1234 :var derp_income=4315
  monthly_balance=derp_income - derp_expenses
  return monthly_balance*12
#+END_SRC

#+RESULTS:
: 36972

or using calc embedded mode directly.

Best,

>
>  - Chris
>
> Christopher Allan Webber <cwebber@dustycloud.org> writes:
>
>> I see now.
>>
>> #+BEGIN_SRC calc :var foo=5
>> foo + 5 =>
>> #+END_SRC
>>
>> #+RESULTS:
>> : 5 + 5 => 10
>>
>> However, this isn't as useful as I'd like.  I'd really like to be able
>> to see it say "foo + 5 =>" in the output.  That's clearer which line is
>> being referred to...
>>
>> Christopher Allan Webber <cwebber@dustycloud.org> writes:
>>
>>> Hey all...
>>>
>>> I have:
>>>
>>> #+BEGIN_SRC calc
>>> foo := 5
>>> foo + 5 =>
>>> #+END_SRC
>>>
>>> #+RESULTS:
>>> : foo + 5 => foo + 5
>>>
>>> What I'd like, obviously, is for it to result in:
>>>
>>> #+RESULTS:
>>> : foo + 5 => 10
>>>
>>> I guess I really don't understand how calc support works in org-babel.
>>> Could someone enlighten me?
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-05-28 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-24 22:51 Why doesn't this calc org-babel code work? Christopher Allan Webber
2012-05-24 22:56 ` Christopher Allan Webber
2012-05-24 23:02   ` Christopher Allan Webber
2012-05-28 16:35     ` Eric Schulte

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).