Improve manual for table formulas

* doc/org.texi (Field coordinates in formulas): Rephrase and add an
example with a Lisp formula to copy from remote table.
This commit is contained in:
Michael Brand 2013-10-06 19:01:15 +02:00 committed by Carsten Dominik
parent aff4f10d79
commit 9bbdd22045
1 changed files with 20 additions and 13 deletions

View File

@ -2551,21 +2551,28 @@ for Calc}.
@cindex row, of field coordinates @cindex row, of field coordinates
@cindex column, of field coordinates @cindex column, of field coordinates
For Calc formulas and Lisp formulas @code{@@#} and @code{$#} can be used to One of the very first actions during evaluation of Calc formulas and Lisp
get the row or column number of the field where the formula result goes. formulas is to substitute @code{@@#} and @code{$#} in the formula with the
The traditional Lisp formula equivalents are @code{org-table-current-dline} row or column number of the field where the current result will go to. The
and @code{org-table-current-column}. Examples: traditional Lisp formula equivalents are @code{org-table-current-dline} and
@code{org-table-current-column}. Examples:
@example @table @code
if(@@# % 2, $#, string("")) @r{column number on odd lines only} @item if(@@# % 2, $#, string(""))
$3 = remote(FOO, @@@@#$2) @r{copy column 2 from table FOO into} Insert column number on odd rows, set field to empty on even rows.
@r{column 3 of the current table} @item $2 = '(identity remote(FOO, @@@@#$1))
@end example Copy text or values of each row of column 1 of the table named @code{FOO}
into column 2 of the current table.
@item @@3 = 2 * remote(FOO, @@1$$#)
Insert the doubled value of each column of row 1 of the table named
@code{FOO} into row 3 of the current table.
@end table
@noindent For the second example, table FOO must have at least as many rows @noindent For the second/third example, the table named @code{FOO} must have
as the current table. Note that this is inefficient@footnote{The computation time scales as at least as many rows/columns as the current table. Note that this is
O(N^2) because table FOO is parsed for each field to be copied.} for large inefficient@footnote{The computation time scales as O(N^2) because the table
number of rows. named @code{FOO} is parsed for each field to be read.} for large number of
rows/columns.
@subsubheading Named references @subsubheading Named references
@cindex named references @cindex named references