Debian Codegraph @

tutorial/intro_hello.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>1.5 A Hello World Document</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">1.5 A Hello World Document</FONT><BR>
102
103
104
105 <P>Just as one starts the process of learning a new
106 programming language with a "Hello World" program,
107 when learning FunnelWeb, you can start with a "Hello
108 World" document. And here it is! Edit a text file called
109 <SAMP>hello.fw</SAMP> and put the following text in it. (Note:
110 The second character is the letter "Oh", not the
111 digit "Zero").
112
113 <P>
114 <PRE>
115 @O@&lt;hello.txt@&gt;@{Hello World@+@}
116 </PRE>
117
118 <P>To "run" this "program", invoke
119 FunnelWeb using the "<TT>fw</TT>" command as
120 follows.
121
122 <P>
123 <PRE>
124 fw hello
125 </PRE>
126
127 <P><I>If this command doesn't work, then chances are
128 that FunnelWeb has not been installed on your machine. Refer
129 to the main <A HREF="../"
130 TARGET="funnelweb"
131 onClick="window.open('','funnelweb','location,status,menubar,scrollbars,resizable',false).focus(); return true;"
132 >FunnelWeb</A> web for full details on how to
133 obtain and install a copy of FunnelWeb.</I>&nbsp;
134
135 <P>There should be no errors. If there are, have a look at
136 the listing file <SAMP>hello.lis</SAMP>, which should contain
137 an explanation of the error, and compare the area in the
138 file where the error occurred with the text above. If there
139 are no errors, you will find that the following two files
140 have been created.
141
142 <P>
143 <PRE>
144 hello.lis - The LISTING file.
145 hello.txt - The PRODUCT file.
146 </PRE>
147
148 <P>Take a look at <SAMP>hello.txt</SAMP>. It should contain a
149 single line with the text <SAMP>Hello World</SAMP>. Let's take
150 another look at the input file.
151
152 <P>
153 <PRE>
154 @O@&lt;hello.txt@&gt;@{Hello World@+@}
155 </PRE>
156
157 <P>The whole structure of the input file is controlled by
158 "<TT>@</TT>", called the <STRONG>special character</STRONG>,
159 which introduces <STRONG>special sequence</STRONG>s. A
160 scanner's-eye view of the command line looks like this:
161
162 <P>
163 <PRE>
164 @O @&lt; "hello.txt" @&gt;
165 @{ "Hello World" @+ @}
166 </PRE>
167
168 <P>The <SAMP>@</SAMP> character controls everything. In this
169 file we have six different special sequences that together
170 form a single macro definition. The
171 <SAMP>@&lt;</SAMP> and
172 <SAMP>@&gt;</SAMP> delimit the name of the
173 macro. The <SAMP>@O</SAMP> signals the start of
174 the macro definition and indicates that the macro is to be
175 connected to a product file with the same name as the macro
176 (This is is why we got a product file when we ran
177 FunnelWeb). The <SAMP>@{</SAMP> and
178 <SAMP>@}</SAMP> delimit the body of the
179 macro. Finally, the <SAMP>@+</SAMP> instructs that
180 an end of line sequence should be inserted at that point in
181 the product file.
182
183 <P>If you think this syntax looks messy, then you're
184 right. It <I>is</I>&nbsp; messy. FunnelWeb <I>could</I>&nbsp; have
185 employed a "simpler" notation in which more of the
186 <SAMP>@</SAMP> sequences were eliminated. For example:
187
188 <P>
189 <PRE>
190 Warning: This example is NOT legal FunnelWeb.
191
192 #hello.txt{Hello World+}
193 </PRE>
194
195 <P>However, if such a syntax were used, the user (you!)
196 would have to remember that <SAMP>#</SAMP> starts a new macro.
197 You would also have to remember that the characters
198 <SAMP>}</SAMP> and <SAMP>+</SAMP> cannot be used in a macro body
199 without a fuss. And so on. FunnelWeb is messier, but
200 provides one simple rule:
201 <I>Nothing special happens unless the special character
202 <SAMP>@</SAMP> appears.</I>&nbsp;
203
204 <P>This means that in FunnelWeb, you can look at large
205 blocks of text in the confidence that (unlike for the C
206 pre-processor) there are no macro
207 calls hidden in there. If there were, there would be an
208 <SAMP>@</SAMP> character! (The only exception to this
209 rule occurs where the user has explicitly changed the
210 special character using the <SAMP>@=</SAMP>
211 special sequence).
212
213 <P>Let's take another look at the hello world program.
214
215 <P>
216 <PRE>
217 @O@&lt;hello.txt@&gt;@{Hello World@+@}
218 </PRE>
219
220 <P>In its current form, it consists of a single macro
221 definition. This definition, while completely valid on its
222 own, only represents half the power of FunnelWeb. In fact
223 you could say that it is a "Hello Northern Hemisphere
224 Program". To turn
225 it into a proper FunnelWeb "Hello World" program, we
226 need to add some documentation.
227
228 <P>A FunnelWeb input file consists of a sequence of macro
229 definitions surrounded by a sea of documentation which is
230 just ordinary text. Modify your hello world document so that
231 it looks like this:
232
233 <P>
234 <PRE>
235 This hello world document was
236 created by -insert your name here-.
237
238 @O@&lt;hello.txt@&gt;@{Hello World@+@}
239
240 It writes out a file called hello.txt
241 containing the string ``Hello World''.
242 </PRE>
243
244 <P>Now run it through FunnelWeb, but this time, add a
245 <SAMP>+t</SAMP> to the command line.
246
247 <P>
248 <PRE>
249 fw hello +t
250 </PRE>
251
252 <P>If all goes well, you should find that you now have
253
254 <P>
255 <PRE>
256 hello.lis - A LISTING file.
257 hello.tex - A DOCUMENTATION file (in TeX format).
258 hello.txt - A PRODUCT file.
259 </PRE>
260
261 <P>Take a look at <SAMP>hello.txt</SAMP>. You will find that
262 it is identical to the <SAMP>hello.txt</SAMP> of the previous
263 run. Only macro definitions affect the product files that
264 FunnelWeb produces (as a result of <SAMP>@O</SAMP> macro
265 definitions). The surrounding documentation has <I>no</I>&nbsp;
266 effect. In contrast, the new file, <SAMP>hello.tex</SAMP> (have
267 a look at it now) which was created as a result of your
268 adding the <SAMP>+t</SAMP> option contains a fairly full
269 representation of the input file. Whereas
270 <SAMP>hello.txt</SAMP> is the <I>product file</I>&nbsp; of
271 FunnelWeb, <SAMP>hello.tex</SAMP> is the <I>documentation
272 file</I>&nbsp;.
273
274 <P>Try typesetting the documentation file now using the
275 TeX typesetting program. Then print it. The following
276 commands are an example of the sort of commands you will
277 have to give to do this.
278
279 <P>
280 <PRE>
281 tex hello ! Typeset the doc.
282 lpr -Pcslw -d hello.dvi ! Print the typeset doc.
283 </PRE>
284
285 <P>If you don't have TeX, you can generate an
286 HTML documentation file instead. Here's how:
287
288 <P>
289 <PRE>
290 fw hello +u
291 </PRE>
292
293 <P>The documentation should consist of single page containing
294 the two lines of documentation along with a typeset representation
295 of the macro. At this point, you have exercised the two main
296 aspects of FunnelWeb.
297 Starting with an input file containing macros (or in this
298 case macro) and documentation, you have successfully
299 generated a product file based on the macros, and a
300 documentation file, based on the entire document.
301
302 <P>The next two sections focus on FunnelWeb's macro
303 facilities and its typesetting facilities. By tradition, the
304 generation of program files from a literate text is called
305 <STRONG>Tangling</STRONG>, and the generation of typeset
306 documentation is called <STRONG>Weaving</STRONG>. In
307 FunnelWeb, these two functions are aspects of a single
308 computer program. However, in Knuth's WEB
309 system, the two functions are embodied in two separate
310 computer programs called Tangle and Weave, presumably
311 because, as everyone knows, "it takes two to
312 Tangle".
313
314
315 <P>
316 <TABLE WIDTH="100%">
317 <TR>
318 <TD ALIGN="left" VALIGN="bottom"><A HREF="intro_tutorial.html"><IMG SRC="binary/fw_left.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Prev"></A></TD>
319 <TD ALIGN="center" VALIGN="bottom"><A HREF="intro.html"><IMG SRC="binary/fw_up.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Up"></A></TD>
320 <TD ALIGN="right" VALIGN="bottom"><A HREF="intro.html"><IMG SRC="binary/fw_up.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Up"></A></TD>
321 </TR>
322 </TABLE>
323
324
325
326 <HR>
327 <FONT SIZE="2">
328 <A HREF="mailto:[email protected]">Webmaster</A>&nbsp;&nbsp;&nbsp;
329 <A HREF="copyright.html">Copyright &copy; Ross N. Williams 1992,1999. All rights reserved.</A><BR>
330 </FONT>
331
332 </FONT>
333 </TD>
334 </TR>
335 </TABLE>
336
337
338 </BODY>
339
340 <!-- *********************************************************************** -->
341 <!-- End Of A FunnelWeb Manual Web Page (www.ross.net/funnelweb/) -->
342 <!-- *********************************************************************** -->
343
344 </HTML>