From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: column formulas: Row descriptor -1 used in line ### leads outside table Date: Thu, 04 Aug 2011 14:41:00 -0400 Message-ID: <16318.1312483260@alphaville.dokosmarshall.org> References: <87wrett4p1.fsf@notam02.no> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:54823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qp2qx-0003Yq-GI for emacs-orgmode@gnu.org; Thu, 04 Aug 2011 14:41:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qp2qw-0003Do-3v for emacs-orgmode@gnu.org; Thu, 04 Aug 2011 14:41:07 -0400 Received: from g4t0014.houston.hp.com ([15.201.24.17]:38380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qp2qv-0003Cn-IU for emacs-orgmode@gnu.org; Thu, 04 Aug 2011 14:41:05 -0400 In-Reply-To: Message from andersvi@notam02.no of "Thu, 04 Aug 2011 20:24:58 +0200." <87wrett4p1.fsf@notam02.no> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: andersvi@notam02.no Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org andersvi@notam02.no wrote: > Anyone have suggestions about how i can have a column-formula refer to > value in previous row, but ignore the row before the first line? > > Something like this: > > | 1 | 4 | | > | 2 | 7 | | > | 3 | 1 | | > #+TBLFM: $2=random(10)::$3=(@-1$2)-$2 > > Evaluating this returns an error: > > "Row descriptor -1 used in line 547 leads outside table" > > I tried using a lisp-expression to dispatch on the row-number, but it > doesnt seem to consider 'if as a special-form, trying to evaluate its > last argument anyhow. > > | 1 | 2 | | > | 2 | 6 | | > | 3 | 2 | | > #+TBLFM: $2=random(10)::$3='(if (< @# 3) 0 (- @-1$2 $2)) > > but get the same error. > Set the cell in the first line explicitly with a field formula (or just a value): it overrides the column formula. Something like this: #+TBLFM: $2=random(10)::$3=(@-1$2)-$2::@1$3 = 0 Nick