1 | //////////////////////////////////////////////////////////////////// |
---|
2 | // version string automatically expanded by CVS |
---|
3 | version="$Id: template.lib,v 1.8 2000-12-19 18:31:48 obachman Exp $"; |
---|
4 | // summary description of the library |
---|
5 | category="Miscellaneous"; |
---|
6 | info=" |
---|
7 | LIBRARY: template.lib A TEMPLATE FOR A SINGULAR LIBRARY |
---|
8 | |
---|
9 | AUTHOR: Olaf Bachmann, email: obachman@mathematik.uni-kl.de |
---|
10 | |
---|
11 | SEE ALSO: standard_lib, Guidelines for writing a library, |
---|
12 | Typesetting of help strings |
---|
13 | |
---|
14 | KEYWORDS: library, template.lib; template.lib; library, info string |
---|
15 | |
---|
16 | PROCEDURES: |
---|
17 | mdouble(int) return double of int argument |
---|
18 | mtripple(int) return three times int argument |
---|
19 | msum([int,..,int]) sum of int arguments |
---|
20 | "; |
---|
21 | //////////////////////////////////////////////////////////////////// |
---|
22 | proc mdouble(int i) |
---|
23 | "USAGE: mdouble(i); i int |
---|
24 | RETURN: int: i+i |
---|
25 | NOTE: Help string is in pure ASCII |
---|
26 | this line starts on a new line since previous line is short |
---|
27 | mdouble(i): no new line |
---|
28 | SEE ALSO: msum, mtripple, Typesetting of help strings |
---|
29 | KEYWORDS: procedure, ASCII help |
---|
30 | EXAMPLE: example mdouble; shows an example" |
---|
31 | { |
---|
32 | return (i + i); |
---|
33 | } |
---|
34 | example |
---|
35 | { "EXAMPLE:"; echo = 2; |
---|
36 | mdouble(0); |
---|
37 | mdouble(-1); |
---|
38 | } |
---|
39 | //////////////////////////////////////////////////////////////////// |
---|
40 | proc mtripple(int i) |
---|
41 | "@c we do texinfo here |
---|
42 | @table @asis |
---|
43 | @item @strong{Usage:} |
---|
44 | @code{mtripple(i)}; @code{i} int |
---|
45 | |
---|
46 | @item @strong{Return:} |
---|
47 | int: @math{i+i+i} |
---|
48 | @item @strong{Note:} |
---|
49 | Help is in pure Texinfo |
---|
50 | @*This help string is written in texinfo, which enables you to use, |
---|
51 | among others, the @@math command for mathematical typesetting (like |
---|
52 | @math{\alpha, \beta}). |
---|
53 | @*It also gives more control over the layout, but is, admittingly, |
---|
54 | more cumbersome to write. |
---|
55 | @end table |
---|
56 | @c use @c ref contstuct for references |
---|
57 | @cindex procedure, texinfo help |
---|
58 | @c ref |
---|
59 | @strong{See also:} |
---|
60 | @ref{mdouble}, @ref{msum}, @ref{Typesetting of help strings} |
---|
61 | @c ref |
---|
62 | " |
---|
63 | { |
---|
64 | return (i + i + i); |
---|
65 | } |
---|
66 | example |
---|
67 | { "EXAMPLE:"; echo = 2; |
---|
68 | mtripple(0); |
---|
69 | mtripple(-1); |
---|
70 | } |
---|
71 | //////////////////////////////////////////////////////////////////// |
---|
72 | proc msum(list #) |
---|
73 | "USAGE: msum([i_1,..,i_n]); @code{i_1,..,i_n} def |
---|
74 | RETURN: Sum of int arguments |
---|
75 | NOTE: This help string is written in a mixture of ASCII and texinfo |
---|
76 | @* Use a @ref constructs for references (like @pxref{mtripple}) |
---|
77 | @* Use @code for typewriter font (like @code{i_1}) |
---|
78 | @* Use @math for simple math mode typesetting (like @math{i_1}). |
---|
79 | @* Note: No parenthesis like } are allowed inside @math and @code |
---|
80 | @* Use @example for indented preformatted text typeset in typewriter |
---|
81 | font like |
---|
82 | @example |
---|
83 | this --> that |
---|
84 | @end example |
---|
85 | Use @format for preformatted text typeset in normal font |
---|
86 | @format |
---|
87 | this --> that |
---|
88 | @end format |
---|
89 | Use @texinfo for text in pure texinfo |
---|
90 | @texinfo |
---|
91 | @expansion{} |
---|
92 | @tex |
---|
93 | $i_{1,1}$ |
---|
94 | @end tex |
---|
95 | |
---|
96 | @end texinfo |
---|
97 | Notice that |
---|
98 | automatic linebreaking is still in affect (like on this line). |
---|
99 | SEE ALSO: mdouble, mtripple, Typesetting of help strings |
---|
100 | KEYWORDS: procedure, ASCII/Texinfo help |
---|
101 | EXAMPLE: example msum; shows an example" |
---|
102 | { |
---|
103 | if (size(#) == 0) { return (0);} |
---|
104 | if (size(#) == 1) { return (#[1]);} |
---|
105 | int i; |
---|
106 | def s = #[1]; |
---|
107 | for (i=2; i<=size(#); i++) |
---|
108 | { |
---|
109 | s = s + #[i]; |
---|
110 | } |
---|
111 | return (s); |
---|
112 | } |
---|
113 | example |
---|
114 | { "EXAMPLE:"; echo = 2; |
---|
115 | msum(); |
---|
116 | msum(4); |
---|
117 | msum(1,2,3,4); |
---|
118 | } |
---|