| 1 |
|
| 2 |
<HTML> |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 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 <B Very Important</B>! |
| 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 |
@$@<B@>@(@1@)@M@{<B>@1</B>@} |
| 124 |
... |
| 125 |
This is @<B@>@(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 |
@$@<Begin page@>@(@1@)@M@{ |
| 152 |
<HTML> |
| 153 |
<HEAD> |
| 154 |
<TITLE>@1</TITLE> |
| 155 |
</HEAD> |
| 156 |
<BODY BGCOLOR=#FFFFFF TEXT=#000033> |
| 157 |
@} |
| 158 |
|
| 159 |
@$@<End page@>@M@{ |
| 160 |
</BODY> |
| 161 |
</HTML> |
| 162 |
@} |
| 163 |
|
| 164 |
@!************************************************ |
| 165 |
|
| 166 |
@O@<index.html@>@{ |
| 167 |
@<Begin page@>@(Dave's Home Page@) |
| 168 |
|
| 169 |
<P>Welcome to my home page. Check out my |
| 170 |
<A HREF="@<Links FILE@>">links page</A> and my |
| 171 |
<A HREF="@<Hobbies FILE@>">hobbies page</A>. |
| 172 |
|
| 173 |
@<End page@> |
| 174 |
@} |
| 175 |
|
| 176 |
@!************************************************ |
| 177 |
|
| 178 |
@$@<Links FILE@>@M@{links.html@} |
| 179 |
@O@<links.html@>@{ |
| 180 |
@<Begin page@>@(Dave's Links@) |
| 181 |
|
| 182 |
<P>Here are my links: |
| 183 |
|
| 184 |
<P> |
| 185 |
<A HREF="http://www.yahoo.com/">Yahoo</A><BR> |
| 186 |
<A HREF="http://www.dilbert.com/">Dilbert</A><BR> |
| 187 |
|
| 188 |
@<End page@> |
| 189 |
@} |
| 190 |
|
| 191 |
@!************************************************ |
| 192 |
|
| 193 |
@$@<Hobbies FILE@>@M@{hobbies.html@} |
| 194 |
@O@<hobbies.html@>@{ |
| 195 |
@<Begin page@>@(Dave's Hobbies@) |
| 196 |
|
| 197 |
<P>This page is under construction! |
| 198 |
|
| 199 |
@<End page@> |
| 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 |
@$@<Marvin Hylrzbvwryvitz@>@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 |
@$@<Marvin@>@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 |
@$@<Email FIELD@>@M@{email_adr@} |
| 286 |
|
| 287 |
@!************************************************ |
| 288 |
|
| 289 |
@O@<order.html@>@{ |
| 290 |
@<Begin page@>@(Order Form@) |
| 291 |
|
| 292 |
<P> |
| 293 |
<FORM ...> |
| 294 |
<INPUT TYPE="text" NAME="@<Email FIELD@>"> |
| 295 |
... |
| 296 |
</FORM> |
| 297 |
|
| 298 |
@<End page@> |
| 299 |
@} |
| 300 |
|
| 301 |
@!************************************************ |
| 302 |
|
| 303 |
@O@<order.cgi@>@{@- |
| 304 |
@<Begin CGI page@> |
| 305 |
... |
| 306 |
$v = $form{'@<Email FIELD@>'}; |
| 307 |
@<End CGI page@> |
| 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 |
@$@<Business EMAIL@>@M@{dave@@someisp.com.au@} |
| 346 |
@$@<Personal EMAIL@>@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 |
@$@<Business EMAIL@>@M@{dave@@megacorp.com.au@} |
| 356 |
@$@<Personal EMAIL@>@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> |
| 385 |
<A HREF="copyright.html">Copyright © 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 |
|
| 398 |
|
| 399 |
|
| 400 |
</HTML> |