summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex')
-rw-r--r--Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex19
1 files changed, 18 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex b/Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex
index 9cbde6945eb..aaa0398f468 100644
--- a/Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex
+++ b/Master/texmf-dist/doc/latex/spreadtab/spreadtab_doc_en.tex
@@ -69,7 +69,7 @@
numbersep=1em,classoffset=1,%
morekeywords={% les macros et commandes de spreadtab
spreadtab,SThiderow,SThidecol,STsavecell,STautoround,STmessage,STsetdecimalsep,STtransposecar,STdebug,STdisplaytab,STsetdisplaymarks,%
- STnumericfieldmarker,STtextcell,STcopy,fact,ifeq,ifgt,iflt,numtofrshortdate,%
+ STnumericfieldmarker,STtextcell,STcopy,id,fact,ifeq,ifgt,iflt,numtofrshortdate,%
numtoengshortdate,numtofrlongdate,numtoenglongdate,numtofrmonth,%
numtoengmonth,numtofrday,numtoengday,sum,rand,randint,sumprod,%
frshortdatetonum,engshortdatetonum,englongdatetonum,frlongdatetonum,gcd,lcm},%
@@ -906,6 +906,23 @@ Example :
\end{spreadtab}
\end{center}
+\subsubsection{Identity}
+The simplest macro functions is "\verbinline=id(<number>)=". It returns the number in its argument. Mathematically, it is not very usefull, but with \ST, it makes possible to write mathematical expressions in arguments of macro function where they are not allowed. In the argument of \verbinline=sum= for example.
+
+In the code below, the \verbinline-id- macro function is used to compute the range of cell to add with \verbinline-sum-. In this example, the numeric field of the cell "a2" contains 8. Therefore, "\verbinline=sum([0,-1]:[id(a2-1),-1])/a2=" is equivalent to \verbinline=sum([0,-1]:[7,-1])/8=:
+\begin{lstlisting}
+\begin{spreadtab}{{tabular}{r*{10}c}}
+ @Integers & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
+Mean of the :={8} first integers & sum([0,-1]:[id(a2-1),-1])/a2 \\
+\end{spreadtab}
+\end{lstlisting}
+\begin{center}
+\begin{spreadtab}{{tabular}{r*{10}c}}
+ @Integers & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
+Mean of the :={8} first integers & sum([0,-1]:[id(a2-1),-1])/a2 \\
+\end{spreadtab}
+\end{center}
+
\subsection{Tests}
Three macro-functions provide tests:\par\nobreak
\begin{center}