Debian Codegraph @

tutorial/examples_sharing.html

raw symbols SCIP
1
2 <HTML>
3 <!--
4 ***********************************************************************
5 FUNNELWEB MANUAL WEB PAGE
6 =========================
7 Copyright (c) Ross N. Williams 1992,1999. All rights reserved.
8
9 Permission is granted to redistribute and use this manual in
10 any medium, with or without modification, provided that all
11 notices (including, without limitation, the copyright
12 notice, this permission notice, any record of modification,
13 and all legal notices) are preserved on all copies, that all
14 modifications are clearly marked, and that modified versions
15 are not represented as the original version unless all the
16 modifications since the manual's original release by Ross N.
17 Williams (www.ross.net) consist of translations or other
18 transformations that alter only the manual's form, not its
19 content. THIS MANUAL IS PROVIDED "AS IS" AND WITHOUT ANY
20 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
21 LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
22 FITNESS FOR A PARTICULAR PURPOSE. TO THE EXTENT PERMITTED BY
23 LAW THERE IS ABSOLUTELY NO WARRANTY.
24
25 ***********************************************************************
26 -->
27
28 <HEAD>
29 <TITLE>6.6 Documents That Share Text</TITLE>
30 <STYLE TYPE="text/css"> <!-- A {text-decoration: none} // --> </STYLE>
31 </HEAD>
32 <BODY BACKGROUND="binary/background.gif"
33 BGCOLOR="#FFFFFF"
34 TEXT="#000000"
35 VLINK="#660000"
36 LINK="#FF0000"
37 ALINK="#CC0000">
38
39 <TABLE WIDTH="490">
40 <TR>
41 <TD WIDTH="130" VALIGN="top">
42 <IMG SRC="binary/d_clear.gif" ALT="" WIDTH="130" HEIGHT="1"><BR>
43
44 <FONT SIZE="2">
45 <BR>
46
47 <A HREF="http://www.ross.net/"
48 TARGET="rosshome"
49 onClick="window.open('','rosshome','location,status,menubar,scrollbars,resizable',false).focus(); return true;"
50 >
51 <IMG SRC="binary/rossnet_logo.gif"
52 WIDTH="64" HEIGHT="32"
53 BORDER="0" ALT="RossNet"
54 HSPACE="0" VSPACE="1"></A><BR>
55 <BR>
56
57 <A HREF="../index.shtml"
58 TARGET="funnelweb"
59 onClick="window.open('','funnelweb','location,status,menubar,scrollbars,resizable',false).focus(); return true;"
60 >
61 <IMG SRC="binary/linklogo.gif"
62 WIDTH="64" HEIGHT="32"
63 BORDER="0" ALT="FunnelWeb"
64 HSPACE="0" VSPACE="1"></A><BR>
65 <BR>
66 <TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TR><TD BGCOLOR="#000000">
67 <A HREF="../reference/index.html"
68 TARGET="funnelwebreference"
69 onClick="window.open('','funnelwebreference','location,status,menubar,scrollbars,resizable',false).focus(); return true;"
70 ><FONT COLOR="#FFFFFF"><B>Reference</B></FONT></A><BR>
71 <BR>
72 <A HREF="../developer/index.html"
73 TARGET="funnelwebdeveloper"
74 onClick="window.open('','funnelwebdeveloper','location,status,menubar,scrollbars,resizable',false).focus(); return true;"
75 ><FONT COLOR="#FFFFFF"><B>Developer</B></FONT></A><BR>
76 <BR>
77 <A HREF="index.html"><FONT COLOR="#FFFFFF"><B>Tutorial</B></FONT></A><BR>
78 <A HREF="intro.html"><FONT COLOR="#FFFFFF">1 Introduction</FONT></A><BR>
79 <A HREF="macro.html"><FONT COLOR="#FFFFFF">2 Macros</FONT></A><BR>
80 <A HREF="type.html"><FONT COLOR="#FFFFFF">3 Typesetting</FONT></A><BR>
81 <A HREF="example.html"><FONT COLOR="#FFFFFF">4 Example</FONT></A><BR>
82 <A HREF="hints.html"><FONT COLOR="#FFFFFF">5 Hints</FONT></A><BR>
83 <A HREF="examples.html"><FONT COLOR="#FFFFFF">6 Examples</FONT></A><BR>
84 <A HREF="web.html"><FONT COLOR="#FFFFFF">7 Webmaking</FONT></A><BR>
85
86 <BR>
87 <A HREF="search.html"><FONT COLOR="#FFFFFF"><B>SEARCH</B></FONT></A><BR>
88 </FONT>
89 </TD></TR></TABLE>
90
91
92 </TD>
93 <TD WIDTH="360" VALIGN="top">
94 <FONT SIZE="3">
95
96
97 <A HREF="../reference/index.html"><IMG SRC="binary/title.gif"
98 WIDTH="302" HEIGHT="24"
99 BORDER="0" ALT="FunnelWeb Tutorial Manual"
100 HSPACE="0" VSPACE="0"></A>
101 <P><FONT SIZE="5">6.6 Documents That Share Text</FONT><BR>
102
103
104
105 <P>FunnelWeb is very useful when preparing multiple
106 documents that must share large slabs of identical text that
107 are being constantly modified.
108
109 <P>For example someone preparing two slightly different
110 user manuals for two slightly different audiences might want
111 the manuals to share large slabs of text, while still
112 allowing differences between them. The following example
113 shows how this can be done. The code is cluttered, but this
114 clutter would not be a problem if the lumps of text were
115 moderately large.
116
117 <P>
118 <PRE>
119 @O@&lt;manual1.txt@&gt;==@{@&lt;M1@&gt;@+@}
120 @O@&lt;manual2.txt@&gt;==@{@&lt;M2@&gt;@+@}
121
122 @$@&lt;M1@&gt;+=@{@&lt;T1@&gt;@}
123 @$@&lt;M2@&gt;+=@{@&lt;T1@&gt;@}
124 @$@&lt;T1@&gt;@M==@{@-
125 First lump of text shared by both documents.@+@}
126
127 @$@&lt;M1@&gt;+=@{Text for first document@+@}
128 @$@&lt;M2@&gt;+=@{Text for second document@+@}
129
130 @$@&lt;M1@&gt;+=@{@&lt;T2@&gt;@}
131 @$@&lt;M2@&gt;+=@{@&lt;T2@&gt;@}
132 @$@&lt;T2@&gt;@M==@{@-
133 Second lump of text shared by both documents.@+@}
134 </PRE>
135
136 <P>An alternative approach, which might work better in
137 situations where there are many small differences between
138 the two documents rather than a few large ones, is to define
139 a macro with two arguments, one for each product file
140 document. Write the document from top to bottom, but place
141 all stretches that differ between the two documents in a
142 macro call.
143
144 <P>
145 <PRE>
146 @! Set the definition of @#D to
147 @! @1 to create the shareholders report.
148 @! @2 to create the customers report.
149 @$@#D@(@2@)@M==@{@1@}
150
151 @O@&lt;report.txt@&gt;==@{@-
152 ANNUAL REPORT TO @#D@(Shareholders@,Customers@)
153 =================@#D@(============@,=========@)
154 This has been a very good year for The Very Big
155 Corporation of America. With your help, we have
156 been able to successfully
157 @#D@(@"screw the customers
158 for every cent they have@"@,
159 @"knock the shareholders into
160 submission to bring you lower prices@"@).
161 With gross earnings approaching six trillion
162 dollars, we have been able to
163 @#D@(@"increase dividends@"@,
164 @"lower prices@"@).
165 We expect to have an even better year next year.
166 @}
167 </PRE>
168
169 <P>One application where text sharing can be particularly
170 useful is in the preparation of computer
171 documentation containing
172 examples. For example, a book describing a new programming
173 language might be full of examples of small programs written
174 in the language which the user might want to try without
175 having to type them all in. The "default" approach
176 of keeping a copy of the examples in the text of the book
177 and another copy in separate files is cumbersome and error
178 prone, because both files have to be updated whenever an
179 example is changed. A more sophisticated approach is to
180 store each example in a separate file, and then use the
181 "include file" facility of the word processor to
182 include each example in the text. This is a better solution,
183 but suffers from a few drawbacks. First, when editing the
184 book in a word processor, the examples in the book will not
185 be directly accessible or visible. To see an example, the
186 writer would have to open the file containing the example in
187 a separate window. This could become tedious if the text
188 contained many examples, as many texts do. Furthermore,
189 there is a risk that some example files will be included in
190 the wrong place. Second, because the book is dependent on
191 the included files, the book will end up consisting of a
192 directory of a hundred or more files instead of just a few.
193
194 <P>An alternative solution is to construct a single
195 FunnelWeb <SAMP>.fw</SAMP> file that, when processed, produces
196 both the book file and the example files. This solution
197 assumes that the book consists of a text file containing
198 commands for a typesetter such as TeX.
199
200 <PRE>
201 @O@&lt;Book.tex@&gt;==@{@#B@}
202
203 @$@#B+=@{@-
204 The first step to learning the object oriented
205 AdaCgol++ language is to examine a hello world
206 program.
207
208 \start{verbatim}
209 @&lt;Ex1@&gt;
210 \finish{verbatim}
211 @}
212
213 @$@&lt;Ex1@&gt;==@{@-
214 read iopack@+Enter !World~! !Hello~! ex pr flu X[1]@}
215 @O@&lt;Ex1.c@&gt;==@{@&lt;Ex1@&gt;@}
216
217 @$@#B+=@{@-
218 To understand the program, think of the execution
219 state as a plate of cheese...
220 @}
221 </PRE>
222
223 <P>Most of the file will consist of part
224 definitions of the additive macro <SAMP>@#B</SAMP>.
225 The definition is "broken" to allow a
226 macro definition, wherever an example appears.
227
228 <P>The example above is a little messy because
229 FunnelWeb does not allow macros connected to
230 product files to be called, and it does not have
231 text expressions that write to an product file as
232 well as evaluating to text. Nevertheless, it
233 presents a fairly clean solution to the problem of
234 keeping the example programs in a computing text
235 up to date.
236
237
238 <P>
239 <TABLE WIDTH="100%">
240 <TR>
241 <TD ALIGN="left" VALIGN="bottom"><A HREF="examples_comments.html"><IMG SRC="binary/fw_left.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Prev"></A></TD>
242 <TD ALIGN="center" VALIGN="bottom"><A HREF="examples.html"><IMG SRC="binary/fw_up.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Up"></A></TD>
243 <TD ALIGN="right" VALIGN="bottom"><A HREF="examples_generics.html"><IMG SRC="binary/fw_right.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Next"></A></TD>
244 </TR>
245 </TABLE>
246
247
248
249 <HR>
250 <FONT SIZE="2">
251 <A HREF="mailto:[email protected]">Webmaster</A>&nbsp;&nbsp;&nbsp;
252 <A HREF="copyright.html">Copyright &copy; Ross N. Williams 1992,1999. All rights reserved.</A><BR>
253 </FONT>
254
255 </FONT>
256 </TD>
257 </TR>
258 </TABLE>
259
260
261 </BODY>
262
263 <!-- *********************************************************************** -->
264 <!-- End Of A FunnelWeb Manual Web Page (www.ross.net/funnelweb/) -->
265 <!-- *********************************************************************** -->
266
267 </HTML>