File:
[LON-CAPA] /
loncom /
html /
adm /
help /
tex /
Calling_Functions.tex
Revision
1.4:
download - view:
text,
annotated -
select for diffs
Thu Mar 24 16:22:36 2005 UTC (19 years, 6 months ago) by
albertel
Branches:
MAIN
CVS tags:
version_2_9_X,
version_2_9_99_0,
version_2_9_1,
version_2_9_0,
version_2_8_X,
version_2_8_99_1,
version_2_8_99_0,
version_2_8_2,
version_2_8_1,
version_2_8_0,
version_2_7_X,
version_2_7_99_1,
version_2_7_99_0,
version_2_7_1,
version_2_7_0,
version_2_6_X,
version_2_6_99_1,
version_2_6_99_0,
version_2_6_3,
version_2_6_2,
version_2_6_1,
version_2_6_0,
version_2_5_X,
version_2_5_99_1,
version_2_5_99_0,
version_2_5_2,
version_2_5_1,
version_2_5_0,
version_2_4_X,
version_2_4_99_0,
version_2_4_2,
version_2_4_1,
version_2_4_0,
version_2_3_X,
version_2_3_99_0,
version_2_3_2,
version_2_3_1,
version_2_3_0,
version_2_2_X,
version_2_2_99_1,
version_2_2_99_0,
version_2_2_2,
version_2_2_1,
version_2_2_0,
version_2_1_X,
version_2_1_99_3,
version_2_1_99_2,
version_2_1_99_1,
version_2_1_99_0,
version_2_1_3,
version_2_1_2,
version_2_1_1,
version_2_1_0,
version_2_10_0_RC2,
version_2_10_0_RC1,
version_2_0_X,
version_2_0_99_1,
version_2_0_2,
version_2_0_1,
version_2_0_0,
version_1_99_3,
version_1_99_2,
version_1_99_1_tmcc,
version_1_99_1,
version_1_99_0_tmcc,
version_1_99_0,
bz6209-base,
bz6209,
bz5969,
bz2851,
PRINT_INCOMPLETE_base,
PRINT_INCOMPLETE,
HEAD,
GCI_3,
GCI_2,
GCI_1,
BZ5971-printing-apage,
BZ5434-fox
- the ref has _ in it
\label{Calling_Functions}
With variables, you can store strings or numbers. \textbf{Functions} allow
you to manipulate these strings or numbers. Functions work like mathematical
functions: They take some number of arguments in, and return one argument,
usually a number or a string for our purposes. There are a lot of functions
available in LON-CAPA. You can see a complete list at
\ref{all_functions_table}.
For now, let's just look at some simple examples.
%
\begin{figure}
\begin{lyxcode}
\$a~=~-3.0;
\$b~=~\&sin(\$a);
\$c~=~\&pow(3.0,~\&abs(\$a));
\end{lyxcode}
\caption{Some Function Calls\label{Some Function Calls Figure}}
\end{figure}
In the \textbf{Script} block, function names start with \textbf{\&}. Some
example function calls are shown in figure \ref{Some Function Calls Figure}.
You can see that functions can take either variables, numbers, or the results
of other function calls as parameters. The \texttt{\&sin} function returns
the sine of an angle expressed in radians. \texttt{\&pow} raises the first
parameter to the power of the second parameter. \texttt{\&abs} returns the
absolute value of the argument.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>