emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Karl Voit <devnull@Karl-Voit.at>
To: emacs-orgmode@gnu.org
Subject: Re: Calc: Multiply time (hours) with a float
Date: Mon, 19 Sep 2016 15:18:16 +0200	[thread overview]
Message-ID: <2016-09-19T14-57-54@devnull.Karl-Voit.at> (raw)
In-Reply-To: 87a8f4m596.fsf@luisa.c0t0d0s0.de

* Michael Welle <mwe012008@gmx.net> wrote:
>
> Karl Voit <devnull@Karl-Voit.at> 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.

OK, this is my current issue then.

I'm using Org from git/maint version 8.3.4
(release_8.3.4-33-gd522fc) and GNU Emacs 24.5.1 (i686-pc-mingw32
Windows) as well as Emacs 24.4.1 on GNU/Linux.

Can somebody confirm my #ERROR behavior?

>> #+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.

I'd say the same.

>> #+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 ;). 

I was wondering whether or not the stringification is done before or
after the number-conversion - as a test. It's an #ERROR anyway.

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

... which I tried first, got an #ERROR and analyzed the issue.
Narrowing down to '(org-time-string-to-hours $1) is my issue since
I now understand the handling of $2 which is according to the
documentation.

> 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?

(type-of ...) -> very helpful

| time [h:m:s] |   value | product |
|--------------+---------+---------|
|     09:15:00 | 2.54321 | #ERROR  |
#+TBLFM: @2$3='(message (type-of (org-time-string-to-hours $1)))
#+TBLFM: @2$3='(type-of (org-time-string-to-hours $1))

... both formulas lead to #ERROR in @2$3 with no message in the
*Message* buffer.

From my understanding, the first one should have caused an output of
the type in the *Message* buffer and the second one should have
placed something like "integer" into @2$3. Am I correct?

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

Since the issue is with $1, the (string-to-number $2) (which is
working) doesn't fix the #ERROR issue of $1 :-(


Thank you *very* much for your explanations! I (and hopefully many
others as well) am learning a lot here.

-- 
mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode:
       > get Memacs from https://github.com/novoid/Memacs <

https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github

  reply	other threads:[~2016-09-19 13:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08  8:33 Calc: Multiply time (hours) with a float Karl Voit
2016-09-11 11:45 ` Karl Voit
2016-09-11 12:12   ` Michael Welle
2016-09-18 16:36     ` Karl Voit
2016-09-19  6:49       ` Michael Welle
2016-09-19  6:55         ` Michael Welle
2016-09-19 11:43           ` Karl Voit
2016-09-19 12:41             ` Michael Welle
2016-09-19 13:18               ` Karl Voit [this message]
2016-09-19 13:49                 ` Michael Welle
2016-09-19 15:33                   ` Nick Dokos
2016-09-19 17:45                     ` Michael Welle
2016-09-20 14:17                       ` Karl Voit
2016-09-19 15:33                 ` Bernhard Pröll
2016-09-20 14:23                 ` Calc: Multiply time (hours) with a float - solved by updating Org Karl Voit
2016-09-20 14:58                   ` Michael Welle

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=2016-09-19T14-57-54@devnull.Karl-Voit.at \
    --to=devnull@karl-voit.at \
    --cc=emacs-orgmode@gnu.org \
    --cc=news1142@Karl-Voit.at \
    /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).