Debian Codegraph @

tutorial/web_libraries.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>7.6 Defining Macro Libraries</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">7.6 Defining Macro Libraries</FONT><BR>
102
103
104 <P><BR><FONT SIZE="4"><STRONG>Separating Macros Into An Include File</STRONG></FONT><BR>
105
106 <P>Once you start using FunnelWeb to make webs, you'll discover
107 that you find yourself defining and using the same macros over and
108 over. Rather than redefining them for each new web you make, you
109 can place them all in a FunnelWeb include file, so that they can
110 be included in the FunnelWeb file for each web you make. Suppose
111 that we create a file called <SAMP>style.fwi</SAMP> containing the
112 following text:
113
114 <P>
115 <PRE>
116 @$@&lt;Begin page@&gt;@(@1@)@M@{
117 &lt;HTML&gt;
118 &lt;HEAD&gt;
119 &lt;TITLE&gt;@1&lt;/TITLE&gt;
120 &lt;/HEAD&gt;
121 &lt;BODY BGCOLOR=#FFFFFF TEXT=#000033&gt;
122 @}
123
124 @$@&lt;End page@&gt;@{
125 &lt;/BODY&gt;
126 &lt;/HTML&gt;
127 @}
128
129 @$@&lt;Dilbert@&gt;@Z@M@{@-
130 &lt;A HREF="http://www.dilbert.com/"&gt;Dilbert&lt;/A&gt;@}
131 @$@&lt;Yahoo@&gt;@Z@M@{@-
132 &lt;A HREF="http://www.yahoo.com/"&gt;Yahoo&lt;/A&gt;@}
133 </PRE>
134
135 <P>Once this is done, the main web file can become:
136
137 <P>
138 <PRE>
139 @!************************************************
140
141 @i style
142
143 @!************************************************
144
145 @O@&lt;index.html@&gt;@{
146 @&lt;Begin page@&gt;@(Dave's Home Page@)
147
148 &lt;P&gt;Welcome to my home page. Check out my
149 &lt;A HREF="@&lt;Links FILE@&gt;"&gt;links page&lt;/A&gt;.
150
151 @&lt;End page@&gt;
152 @}
153
154 @!************************************************
155
156 @$@&lt;Links FILE@&gt;@M@{links.html@}
157 @O@&lt;links.html@&gt;@{
158 @&lt;Begin page@&gt;@(Dave's Links@)
159
160 &lt;P&gt;Check out @&lt;Yahoo@&gt; and @&lt;Dilbert@&gt;.
161
162 @&lt;End page@&gt;
163 @}
164
165 @!************************************************
166 </PRE>
167
168 <P>Now we're starting to see some real simplification!
169
170 <P>Note: It's important to attach <SAMP>@Z</SAMP> to any
171 macro you place in an include file that you think might
172 not be called in some webs. If you don't, FunnelWeb will issue
173 "this macro is unused" errors for the included
174 macros you don't use.
175
176 <P><BR><FONT SIZE="4"><STRONG>Library Macros</STRONG></FONT><BR>
177
178 <P>Once you've created one or more macro libraries in the
179 form of FunnelWeb include files, you might find that sometimes
180 you want to redefine some of the macros that the include
181 file provides. For example, suppose that we are preparing
182 an Australian web page and that when we refer to Yahoo, we
183 want to refer to the Australian Yahoo site. If we try to
184 redefine the Yahoo macro:
185
186 <P>
187 <PRE>
188
189 @i style
190
191 ...
192
193 @$@&lt;Yahoo@&gt;@Z@M@{@-
194 &lt;A HREF="http://www.yahoo.com.au/"&gt;Yahoo&lt;/A&gt;@}
195 </PRE>
196
197 <P>then FunnelWeb will issue an error "this macro
198 is already defined". FunnelWeb does not allow macros to
199 be redefined because this could be dangerous in a programming
200 context. It would be very bad if a programmer thought they
201 was invoking one piece of text when they were really invoking
202 another. So FunnelWeb complains.
203
204 <P>To stop FunnelWeb complaining, you can tag with a library
205 macro marker <SAMP>@L</SAMP> any macro in the include file that
206 you want to be able to redefine. For example:
207
208 <P>
209 <PRE>
210 @$@&lt;Dilbert@&gt;@Z@M@L@{@-
211 &lt;A HREF="http://www.dilbert.com/"&gt;Dilbert&lt;/A&gt;@}
212 @$@&lt;Yahoo@&gt;@Z@M@L@{@-
213 &lt;A HREF="http://www.yahoo.com/"&gt;Yahoo&lt;/A&gt;@}
214 </PRE>
215
216 <P>This allows us to redefined the Yahoo and Dilbert macros.
217
218 <P><BR><FONT SIZE="4"><STRONG>Modifying Default Behaviour</STRONG></FONT><BR>
219
220 <P>The library macro mechanism allows you to set up all kinds
221 of default behaviour that can be modified in specific webs. For
222 example, suppose that we rewrote the macro library as:
223
224 <P>
225 <PRE>
226 @$@&lt;Begin page@&gt;@(@1@)@M@{
227 &lt;HTML&gt;
228 &lt;HEAD&gt;
229 &lt;TITLE&gt;@1&lt;/TITLE&gt;
230 &lt;/HEAD&gt;
231 @&lt;Body@&gt;
232 @}
233
234 @$@&lt;End page@&gt;@{
235 &lt;/BODY&gt;
236 &lt;/HTML&gt;
237 @}
238
239 @$@&lt;Body@&gt;@L@{@-
240 &lt;BODY BGCOLOR=#FFFFFF TEXT=#000033&gt;@}
241 </PRE>
242
243 <P>Once this is done, we can modify the page background
244 and colours of any web by redefining the <SAMP>Body</SAMP>
245 macro without having to redefine the start and end
246 of page macros.
247
248 <P>
249 <PRE>
250 @!************************************************
251
252 @i style
253
254 @$@&lt;Body@&gt;@{@-
255 &lt;BODY BGCOLOR=#000000 TEXT=#FFFFFF&gt;@}
256
257 @!************************************************
258
259 @O@&lt;index.html@&gt;@{
260 @&lt;Begin page@&gt;@(Dave's Home Page@)
261
262 &lt;P&gt;Welcome to my home page. Check out my
263 &lt;A HREF="@&lt;Links FILE@&gt;"&gt;links page&lt;/A&gt;.
264
265 @&lt;End page@&gt;
266 @}
267
268 @!************************************************
269
270 @$@&lt;Links FILE@&gt;@M@{links.html@}
271 @O@&lt;links.html@&gt;@{
272 @&lt;Begin page@&gt;@(Dave's Links@)
273
274 &lt;P&gt;Check out @&lt;Yahoo@&gt; and @&lt;Dilbert@&gt;.
275
276 @&lt;End page@&gt;
277 @}
278
279 @!************************************************
280 </PRE>
281
282 <P><BR><FONT SIZE="4"><STRONG>Use Of Additive Macros</STRONG></FONT><BR>
283
284 <P>Additive macros can be used to insert information into
285 the middle of macros already defined. For example, suppose
286 you defined:
287
288 <P>
289 <PRE>
290 @$@&lt;Begin page@&gt;@(@1@)@M@{
291 &lt;HTML&gt;
292 &lt;HEAD&gt;
293 &lt;TITLE&gt;@1&lt;/TITLE&gt;
294 @&lt;Header fields@&gt;
295 &lt;/HEAD&gt;
296 &lt;BODY BGCOLOR=#FFFFFF TEXT=#000033&gt;
297 @}
298
299 @$@&lt;Header fields@&gt;+=@{@}
300 </PRE>
301
302 <P>Once the header fields macro is in place, you can add text such
303 as style commands or keyword tags to each of the pages of your web
304 without having to modify the header include file. Just add a definition,
305 such as the following, to your main FunnelWeb file:
306
307 <P>
308 <PRE>
309 @$@&lt;Header fields@&gt;+=@{
310 &lt;STYLE TYPE="text/css"&gt;
311 &lt;!-- A {text-decoration: none} // --&gt;
312 &lt;/STYLE&gt;
313 @}
314 </PRE>
315
316 <P><BR><FONT SIZE="4"><STRONG>Selecting Absolute Or Relative Links</STRONG></FONT><BR>
317
318 <P>Sometimes it's important to generate a web that uses
319 relative hyperlinks, and sometimes it's important to generate
320 a web that uses absolute hyperlinks. For example, it's important
321 to use relative links if you want to browse a web offline, or
322 if you want to ensure that username and password fields in
323 the URL are not obliterated by the following of an absolute link.
324 Absolute links are important where a web that is normally
325 adjacent to another web (and hence usually links to it using
326 a relative link) is separated and must be browsed offline.
327
328 <P>A good way to organize all this is to define FunnelWeb
329 macros for the URLs of webs in include files, but allow them
330 to be overruled by including files. For example, an
331 file might contain the following definitions:
332
333 <P>
334 <PRE>
335 @$@&lt;Rocksoft WWW@&gt;@Z@M@L@{http://www.rocksoft.com/@}
336 @$@&lt;Ross WWW@&gt;@Z@M@L@{http://www.ross.net/@}
337 @$@&lt;Veracity WWW@&gt;@Z@M@L@{http://www.veracity.com/@}
338 </PRE>
339
340 <P>These symbols are useful for referring to these various
341 webs from within these webs. However, it is convenient for
342 each subweb to refer to other subwebs using a relative path
343 rather than an absolute path, so when generating (say) a
344 subweb of the Ross webspace, the Ross macro could be redefined to:
345
346 <P>
347 <PRE>
348 @$@&lt;Ross WWW@&gt;@Z@M@{../@}
349 </PRE>
350
351 <P>This technique can be used in various forms to manage
352 the links in the online and offline versions of webs.
353
354
355 <P>
356 <TABLE WIDTH="100%">
357 <TR>
358 <TD ALIGN="left" VALIGN="bottom"><A HREF="web_style.html"><IMG SRC="binary/fw_left.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Prev"></A></TD>
359 <TD ALIGN="center" VALIGN="bottom"><A HREF="web.html"><IMG SRC="binary/fw_up.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Up"></A></TD>
360 <TD ALIGN="right" VALIGN="bottom"><A HREF="web_param.html"><IMG SRC="binary/fw_right.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Next"></A></TD>
361 </TR>
362 </TABLE>
363
364
365
366 <HR>
367 <FONT SIZE="2">
368 <A HREF="mailto:[email protected]">Webmaster</A>&nbsp;&nbsp;&nbsp;
369 <A HREF="copyright.html">Copyright &copy; Ross N. Williams 1992,1999. All rights reserved.</A><BR>
370 </FONT>
371
372 </FONT>
373 </TD>
374 </TR>
375 </TABLE>
376
377
378 </BODY>
379
380 <!-- *********************************************************************** -->
381 <!-- End Of A FunnelWeb Manual Web Page (www.ross.net/funnelweb/) -->
382 <!-- *********************************************************************** -->
383
384 </HTML>