Debian Codegraph @

tutorial/web_errors.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.4 Avoiding Errors And Inconsistencies</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.4 Avoiding Errors And Inconsistencies</FONT><BR>
102
103
104 <P>FunnelWeb provides the opportunity to eliminate all kinds of
105 errors and inconsistencies by replacing text names with FunnelWeb
106 macro names that cannot be misspelt without being detected by FunnelWeb.
107 This page provides some examples of this.
108
109 <P><BR><FONT SIZE="4"><STRONG>Minor Style Elements</STRONG></FONT><BR>
110
111 <P>Have you ever done this:
112
113 <P>
114 <PRE>
115 This is &lt;B Very Important&lt;/B&gt;!
116 </PRE>
117
118 <P>These kinds of errors can be eliminated by replacing HTML
119 constructs, even simple ones, by FunnelWeb macros:
120
121 <P>
122 <PRE>
123 @$@&lt;B@&gt;@(@1@)@M@{&lt;B&gt;@1&lt;/B&gt;@}
124 ...
125 This is @&lt;B@&gt;@(Very Important@)!
126 </PRE>
127
128 <P>While this is a bit messier, it eliminates the chance of an
129 error because if you get the syntax wrong, FunnelWeb will generate
130 an error at "compile time", which is a lot better than receiving
131 email from some random web visitor. It's true that the same level
132 of checking can be obtained by running an HTML syntax checker
133 over your web. However, if you're using FunnelWeb for all its
134 other benefits, you might as well use this aspect too.
135
136 <P><BR><FONT SIZE="4"><STRONG>File Names In Hyperlinks</STRONG></FONT><BR>
137
138 <P>Another source of error in webs is bad internal links.
139 This can occur when you rename a file and forget to "fix up"
140 all the links to it, and when you make a typing error when
141 typing in a filename in a hyperlink.
142
143 <P>You can use FunnelWeb to eliminate both of these kinds
144 of error, by defining a macro for each output file. This is
145 easier to do than explain:
146
147 <P>
148 <PRE>
149 @!************************************************
150
151 @$@&lt;Begin page@&gt;@(@1@)@M@{
152 &lt;HTML&gt;
153 &lt;HEAD&gt;
154 &lt;TITLE&gt;@1&lt;/TITLE&gt;
155 &lt;/HEAD&gt;
156 &lt;BODY BGCOLOR=#FFFFFF TEXT=#000033&gt;
157 @}
158
159 @$@&lt;End page@&gt;@M@{
160 &lt;/BODY&gt;
161 &lt;/HTML&gt;
162 @}
163
164 @!************************************************
165
166 @O@&lt;index.html@&gt;@{
167 @&lt;Begin page@&gt;@(Dave's Home Page@)
168
169 &lt;P&gt;Welcome to my home page. Check out my
170 &lt;A HREF="@&lt;Links FILE@&gt;"&gt;links page&lt;/A&gt; and my
171 &lt;A HREF="@&lt;Hobbies FILE@&gt;"&gt;hobbies page&lt;/A&gt;.
172
173 @&lt;End page@&gt;
174 @}
175
176 @!************************************************
177
178 @$@&lt;Links FILE@&gt;@M@{links.html@}
179 @O@&lt;links.html@&gt;@{
180 @&lt;Begin page@&gt;@(Dave's Links@)
181
182 &lt;P&gt;Here are my links:
183
184 &lt;P&gt;
185 &lt;A HREF="http://www.yahoo.com/"&gt;Yahoo&lt;/A&gt;&lt;BR&gt;
186 &lt;A HREF="http://www.dilbert.com/"&gt;Dilbert&lt;/A&gt;&lt;BR&gt;
187
188 @&lt;End page@&gt;
189 @}
190
191 @!************************************************
192
193 @$@&lt;Hobbies FILE@&gt;@M@{hobbies.html@}
194 @O@&lt;hobbies.html@&gt;@{
195 @&lt;Begin page@&gt;@(Dave's Hobbies@)
196
197 &lt;P&gt;This page is under construction!
198
199 @&lt;End page@&gt;
200 @}
201
202 @!************************************************
203 </PRE>
204
205 <P>Again, this technique introduces a little messiness, but
206 the benefits it brings are significant. Once you have deployed
207 this technique throughout your web source file, you will then
208 be free to change the names of any of your files without ever
209 having to worry about fixing up any links - they will all be
210 fixed automatically! Furthermore, if you delete an output
211 file from your FunnelWeb source file, FunnelWeb will alert
212 you to any "dangling links" because the references to the
213 deleted page take the form of calls to a macro that is no
214 longer defined! Of course, this only works if you don't mark
215 your filename macros with <SAMP>@Z</SAMP>.
216
217 <P>The only thing you have to get right is to ensure that
218 the filename of the output macro is the same as the value
219 of the corresponding naming macro. This isn't too hard to
220 do because they are always on adjacent lines.
221
222 <P>The benefit of eliminating all bad links from one's
223 web is a benefit that can be obtained by running an external
224 web analysis tool over your web. However, by using FunnelWeb
225 file naming macros, you can be SURE that the web can never
226 be generated with a bad link, whereas the web analysis tool
227 only works if you remember to run it!
228
229 <P><BR><FONT SIZE="4"><STRONG>People's Names</STRONG></FONT><BR>
230
231 <P>Sometimes you might have to create a web that contains lots
232 of long names that are hard to remember or spell. FunnelWeb
233 can help here by eliminating the chance of error. Just define
234 each name as macro and always call the macro when using the
235 name. The benefit of doing this is that FunnelWeb will always
236 detect a spelling error because if you make a spelling error
237 in the macro name, FunnelWeb will generate a "macro not defined"
238 error.
239
240 <P>
241 <PRE>
242 @$@&lt;Marvin Hylrzbvwryvitz@&gt;@M@{Marvin Hylrzbvwryvitz@}
243 </PRE>
244
245 <P>If you want to, you could used a shortened form. For example:
246
247 <P>
248 <PRE>
249 @$@&lt;Marvin@&gt;@M@{Marvin Hylrzbvwryvitz@}
250 </PRE>
251
252 <P><BR><FONT SIZE="4"><STRONG>CGI Form Fields</STRONG></FONT><BR>
253
254 <P>One of the organizational challenges of implementing
255 CGI form processing is getting all the field names right.
256 Because (normally) the form is in one file, and the CGI
257 script that processes it is in another file, it's very
258 easy to accidentally use different names for the same
259 field. For example, you might use <SAMP>email_adr</SAMP> in
260 one and <SAMP>email-adr</SAMP> in the other.
261
262 <P>FunnelWeb can be used to completely eliminate this
263 problem as follows:
264
265 <P>
266 <OL>
267
268 <LI> Put both the HTML file containing the form and the
269 CGI file that processes it within the <SAMP>.fw</SAMP> file
270 that embodies your web.
271
272 <BR><BR>
273
274 <LI> Define a macro for the name of each field and use
275 the macro in both the form and the CGI script.
276
277 </OL>
278
279 <P>Here's an example:
280
281 <P>
282 <PRE>
283 @!************************************************
284
285 @$@&lt;Email FIELD@&gt;@M@{email_adr@}
286
287 @!************************************************
288
289 @O@&lt;order.html@&gt;@{
290 @&lt;Begin page@&gt;@(Order Form@)
291
292 &lt;P&gt;
293 &lt;FORM ...&gt;
294 &lt;INPUT TYPE="text" NAME="@&lt;Email FIELD@&gt;"&gt;
295 ...
296 &lt;/FORM&gt;
297
298 @&lt;End page@&gt;
299 @}
300
301 @!************************************************
302
303 @O@&lt;order.cgi@&gt;@{@-
304 @&lt;Begin CGI page@&gt;
305 ...
306 $v = $form{'@&lt;Email FIELD@&gt;'};
307 @&lt;End CGI page@&gt;
308 @}
309
310 @!************************************************
311 </PRE>
312
313 <P>This technique more or less completely eliminates
314 mismatch errors in form field names, for if any such error
315 is made, FunnelWeb will generate a "macro not defined"
316 error. All you have to do to benefit from this technique
317 is get into the habit of using it.
318
319 <P><BR><FONT SIZE="4"><STRONG>When Global Replace Fails</STRONG></FONT><BR>
320
321 <P>Many people who write HTML directly use nerve wracking
322 multi-file global replaces to perform the kind of web
323 parameterization that FunnelWeb makes so easy.
324 Unfortunately, these global replacements can go badly wrong
325 because the target text may be used in many different
326 contexts. In some cases, this approach fails completely.
327
328 <P>For example, suppose that you have to create a hundred
329 page web that has to be laced with two email addresses: a
330 "business" email address and a "personal" email address. No
331 problem so far. However, suppose that you haven't yet chosen
332 a business domain name and, as a result, at the current
333 time, the two email addresses are the same! If this were the
334 case, you would have to put your address throughout all the
335 pages and would LOSE the information of which were supposed
336 to be business addresses and which were supposed to be
337 personal ones.
338
339 <P>FunnelWeb solves this problem (and others like it)
340 completely by allowing you to define two macros one for each
341 context. For example:
342
343 <P>
344 <PRE>
345 @$@&lt;Business EMAIL@&gt;@M@{dave@@someisp.com.au@}
346 @$@&lt;Personal EMAIL@&gt;@M@{dave@@someisp.com.au@}
347 </PRE>
348
349 <P>These macros can then be used as appropriate. Later,
350 when the domain name comes through and the business address
351 changes, all that needs to be changed is a single definition:
352
353 <P>
354 <PRE>
355 @$@&lt;Business EMAIL@&gt;@M@{dave@@megacorp.com.au@}
356 @$@&lt;Personal EMAIL@&gt;@M@{dave@@someisp.com.au@}
357 </PRE>
358
359 <P>There is no need to perform a multi-file global replace
360 and evaluate the context of the use of each email address,
361 as the information was not lost when the web was originally
362 created, because of the two macros.
363
364 <P>This example is just one of many similar situations that
365 arise. By locating all the pages of your web in a single file
366 and allowing you to define macros for different purposes,
367 you can eliminate much of the time and danger of global
368 replacements.
369
370
371 <P>
372 <TABLE WIDTH="100%">
373 <TR>
374 <TD ALIGN="left" VALIGN="bottom"><A HREF="web_messy.html"><IMG SRC="binary/fw_left.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Prev"></A></TD>
375 <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>
376 <TD ALIGN="right" VALIGN="bottom"><A HREF="web_style.html"><IMG SRC="binary/fw_right.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Next"></A></TD>
377 </TR>
378 </TABLE>
379
380
381
382 <HR>
383 <FONT SIZE="2">
384 <A HREF="mailto:[email protected]">Webmaster</A>&nbsp;&nbsp;&nbsp;
385 <A HREF="copyright.html">Copyright &copy; Ross N. Williams 1992,1999. All rights reserved.</A><BR>
386 </FONT>
387
388 </FONT>
389 </TD>
390 </TR>
391 </TABLE>
392
393
394 </BODY>
395
396 <!-- *********************************************************************** -->
397 <!-- End Of A FunnelWeb Manual Web Page (www.ross.net/funnelweb/) -->
398 <!-- *********************************************************************** -->
399
400 </HTML>