emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Calc: Multiply time (hours) with a float


From: Michael Welle
Subject: Re: [O] Calc: Multiply time (hours) with a float
Date: Mon, 19 Sep 2016 14:41:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Hello,

Karl Voit <address@hidden> writes:

> Hallo Michael,
>
> thanks for the pointer to http://orgmode.org/org.html#Formula-syntax-for-Lisp 
> -
> it was very helpful for my understanding.
>
> * Michael Welle <address@hidden> wrote:
>> Hello,
>>
>> Michael Welle <address@hidden> writes:
>> [...]
>>> #+TBLFM: @2$3='(* $2 (org-time-string-to-hours "$1"));L
>> or converting $2 to a number before the calculation should work also,
>> but is more to write ;).
>
> Hm. I still got #ERROR. I reduced my issue to calculate the float (for hours)
> without multiplying it with "value":
strange. I use the current Org version from git and Emacs 25.1.


> | time [h:m:s] |   value | product |
> |--------------+---------+---------|
> |     09:15:00 | 2.54321 | #ERROR  |
>
> #+TBLFM: @2$3='(org-time-string-to-hours $1)
That works for me. The default interpretation of $1 is used and
therefore the value is fed into o-t-s-t-h as string.


> #+TBLFM: @2$3='(org-time-string-to-hours $1);L
That doesn't work. I'm not sure, but I guess it is because you asked for 
literal interpretation and it is not clear what that would mean for
09:15:00.


> #+TBLFM: @2$3='(org-time-string-to-hours "$1");N
Here you ask for interpretation as numbers. So the o-t-s-t-h function
sees a stringified 9 as it's parameter value. Near, but still no t-shirt ;). 


> ... each of the TBLFM results in the same error.
Well, none of them looks like the one I wrote:

#+TBLFM: @2$3='(* $2 (org-time-string-to-hours "$1"));L

You said, that gives an error, too. I have no idea, why. You can use
(message...) and (type-of ...) to look at the types and values that you
feed into your functions. Maybe that gives some insight?

The variant with converting $2 to a number is:
#+TBLFM: @2$3='(* (string-to-number $2) (org-time-string-to-hours $1))

Since the default interpretation is to use strings, the multiplication
sees $2 as a number and $1 is fed to your function as a string, as
required. 

Regards
hmw



reply via email to

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