From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cecil Westerhof Subject: Re: Problem with lisp code in spreadsheet Date: Sun, 17 Jun 2007 08:22:12 +0200 Message-ID: <1182061332.6181.138.camel@Barebusta.DecebalComp> References: <1182016207.6246.127.camel@Barebusta.DecebalComp> <7e4a77e5b8fa3274e12ce0d4c4d53f0a@science.uva.nl> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Hzo9j-0005nE-HV for emacs-orgmode@gnu.org; Sun, 17 Jun 2007 02:22:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Hzo9e-0005iI-UC for emacs-orgmode@gnu.org; Sun, 17 Jun 2007 02:22:34 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hzo9e-0005hu-N2 for emacs-orgmode@gnu.org; Sun, 17 Jun 2007 02:22:30 -0400 Received: from smtp-vbr4.xs4all.nl ([194.109.24.24]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hzo9c-0005DV-4j for emacs-orgmode@gnu.org; Sun, 17 Jun 2007 02:22:29 -0400 Received: from Barebusta.DecebalComp (DecebalComputing.xs4all.nl [213.84.157.201]) by smtp-vbr4.xs4all.nl (8.13.8/8.13.8) with ESMTP id l5H6MDlF066595 for ; Sun, 17 Jun 2007 08:22:13 +0200 (CEST) (envelope-from CecilWesterhof@xs4all.nl) In-Reply-To: <7e4a77e5b8fa3274e12ce0d4c4d53f0a@science.uva.nl> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: org-mode Op zo, 17-06-2007 te 00:14 +0200, schreef Carsten Dominik: > > In a row I have the following formula's: > > =$3 > > ='(getHours $2);%.2f > > ='(/ 67 0.72);%.1f > > ='(/ $3 (getHours $2));%.1f > > This gives: > > 67 > > 0.72 > > 93.1 > > 0.0 > > > > I would expect the last two to return the same number. Why is this not > > the case? > > > > When I change the last formula to: > > ='(/ 67 (getHours $2));%.1f > > I get: > > 93.5 > > > > What is happening here? > > Since I don't know exactly what getHours does, I cannot be sure. > The most likely reason though is that $3 and $2 are interpolated into > Lisp expressions as strings, not as numbers. The tabel: |--------+------+----+-----+------+----+------| | Arnhem | 0:43 | 67 | 0.0 | 93.1 | 67 | 0.72 | |--------+------+----+-----+------+----+------| #+TBLFM: $4='(/ $3 (getHours $2));N%.1f::$5='(/ 67 0.72);%.1f::$6=$3::$7='(getHours $2);%.2f:: getHours: (defun getHours(time) (interactive "sHH:MM: ") (let ((timelist (split-string time ":"))) (+ (string-to-number (car timelist)) (/ (string-to-number (cadr timelist)) 60.0 ) ) ) ) The strange thing is that $3 is 67 and when I change $3 to 67 it works. Even changing the formul to: ='(/ (string-to-number $3) (getHours $2));N%.1f does not work. > See the discussion of the N mode flag in > > http://staff.science.uva.nl/~dominik/Tools/org/org.html#Formula-syntax- > for-Lisp The problem is with $3, so I would not know how to use that. :-{ -- Cecil Westerhof