1 2 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
|
<HTML>
<!--
***********************************************************************
FUNNELWEB MANUAL WEB PAGE
=========================
Copyright (c) Ross N. Williams 1992,1999. All rights reserved.
Permission is granted to redistribute and use this manual in
any medium, with or without modification, provided that all
notices (including, without limitation, the copyright
notice, this permission notice, any record of modification,
and all legal notices) are preserved on all copies, that all
modifications are clearly marked, and that modified versions
are not represented as the original version unless all the
modifications since the manual's original release by Ross N.
Williams (www.ross.net) consist of translations or other
transformations that alter only the manual's form, not its
content. THIS MANUAL IS PROVIDED "AS IS" AND WITHOUT ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
FITNESS FOR A PARTICULAR PURPOSE. TO THE EXTENT PERMITTED BY
LAW THERE IS ABSOLUTELY NO WARRANTY.
***********************************************************************
-->
<HEAD>
<TITLE>7.4 Avoiding Errors And Inconsistencies</TITLE>
<STYLE TYPE="text/css"> <!-- A {text-decoration: none} // --> </STYLE>
</HEAD>
<BODY BACKGROUND="binary/background.gif"
BGCOLOR="#FFFFFF"
TEXT="#000000"
VLINK="#660000"
LINK="#FF0000"
ALINK="#CC0000">
<TABLE WIDTH="490">
<TR>
<TD WIDTH="130" VALIGN="top">
<IMG SRC="binary/d_clear.gif" ALT="" WIDTH="130" HEIGHT="1"><BR>
<FONT SIZE="2">
<BR>
<A HREF="http://www.ross.net/"
TARGET="rosshome"
onClick="window.open('','rosshome','location,status,menubar,scrollbars,resizable',false).focus(); return true;"
>
<IMG SRC="binary/rossnet_logo.gif"
WIDTH="64" HEIGHT="32"
BORDER="0" ALT="RossNet"
HSPACE="0" VSPACE="1"></A><BR>
<BR>
<A HREF="../index.shtml"
TARGET="funnelweb"
onClick="window.open('','funnelweb','location,status,menubar,scrollbars,resizable',false).focus(); return true;"
>
<IMG SRC="binary/linklogo.gif"
WIDTH="64" HEIGHT="32"
BORDER="0" ALT="FunnelWeb"
HSPACE="0" VSPACE="1"></A><BR>
<BR>
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TR><TD BGCOLOR="#000000">
<A HREF="../reference/index.html"
TARGET="funnelwebreference"
onClick="window.open('','funnelwebreference','location,status,menubar,scrollbars,resizable',false).focus(); return true;"
><FONT COLOR="#FFFFFF"><B>Reference</B></FONT></A><BR>
<BR>
<A HREF="../developer/index.html"
TARGET="funnelwebdeveloper"
onClick="window.open('','funnelwebdeveloper','location,status,menubar,scrollbars,resizable',false).focus(); return true;"
><FONT COLOR="#FFFFFF"><B>Developer</B></FONT></A><BR>
<BR>
<A HREF="index.html"><FONT COLOR="#FFFFFF"><B>Tutorial</B></FONT></A><BR>
<A HREF="intro.html"><FONT COLOR="#FFFFFF">1 Introduction</FONT></A><BR>
<A HREF="macro.html"><FONT COLOR="#FFFFFF">2 Macros</FONT></A><BR>
<A HREF="type.html"><FONT COLOR="#FFFFFF">3 Typesetting</FONT></A><BR>
<A HREF="example.html"><FONT COLOR="#FFFFFF">4 Example</FONT></A><BR>
<A HREF="hints.html"><FONT COLOR="#FFFFFF">5 Hints</FONT></A><BR>
<A HREF="examples.html"><FONT COLOR="#FFFFFF">6 Examples</FONT></A><BR>
<A HREF="web.html"><FONT COLOR="#FFFFFF">7 Webmaking</FONT></A><BR>
<BR>
<A HREF="search.html"><FONT COLOR="#FFFFFF"><B>SEARCH</B></FONT></A><BR>
</FONT>
</TD></TR></TABLE>
</TD>
<TD WIDTH="360" VALIGN="top">
<FONT SIZE="3">
<A HREF="../reference/index.html"><IMG SRC="binary/title.gif"
WIDTH="302" HEIGHT="24"
BORDER="0" ALT="FunnelWeb Tutorial Manual"
HSPACE="0" VSPACE="0"></A>
<P><FONT SIZE="5">7.4 Avoiding Errors And Inconsistencies</FONT><BR>
<P>FunnelWeb provides the opportunity to eliminate all kinds of
errors and inconsistencies by replacing text names with FunnelWeb
macro names that cannot be misspelt without being detected by FunnelWeb.
This page provides some examples of this.
<P><BR><FONT SIZE="4"><STRONG>Minor Style Elements</STRONG></FONT><BR>
<P>Have you ever done this:
<P>
<PRE>
This is <B Very Important</B>!
</PRE>
<P>These kinds of errors can be eliminated by replacing HTML
constructs, even simple ones, by FunnelWeb macros:
<P>
<PRE>
@$@<B@>@(@1@)@M@{<B>@1</B>@}
...
This is @<B@>@(Very Important@)!
</PRE>
<P>While this is a bit messier, it eliminates the chance of an
error because if you get the syntax wrong, FunnelWeb will generate
an error at "compile time", which is a lot better than receiving
email from some random web visitor. It's true that the same level
of checking can be obtained by running an HTML syntax checker
over your web. However, if you're using FunnelWeb for all its
other benefits, you might as well use this aspect too.
<P><BR><FONT SIZE="4"><STRONG>File Names In Hyperlinks</STRONG></FONT><BR>
<P>Another source of error in webs is bad internal links.
This can occur when you rename a file and forget to "fix up"
all the links to it, and when you make a typing error when
typing in a filename in a hyperlink.
<P>You can use FunnelWeb to eliminate both of these kinds
of error, by defining a macro for each output file. This is
easier to do than explain:
<P>
<PRE>
@!************************************************
@$@<Begin page@>@(@1@)@M@{
<HTML>
<HEAD>
<TITLE>@1</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF TEXT=#000033>
@}
@$@<End page@>@M@{
</BODY>
</HTML>
@}
@!************************************************
@O@<index.html@>@{
@<Begin page@>@(Dave's Home Page@)
<P>Welcome to my home page. Check out my
<A HREF="@<Links FILE@>">links page</A> and my
<A HREF="@<Hobbies FILE@>">hobbies page</A>.
@<End page@>
@}
@!************************************************
@$@<Links FILE@>@M@{links.html@}
@O@<links.html@>@{
@<Begin page@>@(Dave's Links@)
<P>Here are my links:
<P>
<A HREF="http://www.yahoo.com/">Yahoo</A><BR>
<A HREF="http://www.dilbert.com/">Dilbert</A><BR>
@<End page@>
@}
@!************************************************
@$@<Hobbies FILE@>@M@{hobbies.html@}
@O@<hobbies.html@>@{
@<Begin page@>@(Dave's Hobbies@)
<P>This page is under construction!
@<End page@>
@}
@!************************************************
</PRE>
<P>Again, this technique introduces a little messiness, but
the benefits it brings are significant. Once you have deployed
this technique throughout your web source file, you will then
be free to change the names of any of your files without ever
having to worry about fixing up any links - they will all be
fixed automatically! Furthermore, if you delete an output
file from your FunnelWeb source file, FunnelWeb will alert
you to any "dangling links" because the references to the
deleted page take the form of calls to a macro that is no
longer defined! Of course, this only works if you don't mark
your filename macros with <SAMP>@Z</SAMP>.
<P>The only thing you have to get right is to ensure that
the filename of the output macro is the same as the value
of the corresponding naming macro. This isn't too hard to
do because they are always on adjacent lines.
<P>The benefit of eliminating all bad links from one's
web is a benefit that can be obtained by running an external
web analysis tool over your web. However, by using FunnelWeb
file naming macros, you can be SURE that the web can never
be generated with a bad link, whereas the web analysis tool
only works if you remember to run it!
<P><BR><FONT SIZE="4"><STRONG>People's Names</STRONG></FONT><BR>
<P>Sometimes you might have to create a web that contains lots
of long names that are hard to remember or spell. FunnelWeb
can help here by eliminating the chance of error. Just define
each name as macro and always call the macro when using the
name. The benefit of doing this is that FunnelWeb will always
detect a spelling error because if you make a spelling error
in the macro name, FunnelWeb will generate a "macro not defined"
error.
<P>
<PRE>
@$@<Marvin Hylrzbvwryvitz@>@M@{Marvin Hylrzbvwryvitz@}
</PRE>
<P>If you want to, you could used a shortened form. For example:
<P>
<PRE>
@$@<Marvin@>@M@{Marvin Hylrzbvwryvitz@}
</PRE>
<P><BR><FONT SIZE="4"><STRONG>CGI Form Fields</STRONG></FONT><BR>
<P>One of the organizational challenges of implementing
CGI form processing is getting all the field names right.
Because (normally) the form is in one file, and the CGI
script that processes it is in another file, it's very
easy to accidentally use different names for the same
field. For example, you might use <SAMP>email_adr</SAMP> in
one and <SAMP>email-adr</SAMP> in the other.
<P>FunnelWeb can be used to completely eliminate this
problem as follows:
<P>
<OL>
<LI> Put both the HTML file containing the form and the
CGI file that processes it within the <SAMP>.fw</SAMP> file
that embodies your web.
<BR><BR>
<LI> Define a macro for the name of each field and use
the macro in both the form and the CGI script.
</OL>
<P>Here's an example:
<P>
<PRE>
@!************************************************
@$@<Email FIELD@>@M@{email_adr@}
@!************************************************
@O@<order.html@>@{
@<Begin page@>@(Order Form@)
<P>
<FORM ...>
<INPUT TYPE="text" NAME="@<Email FIELD@>">
...
</FORM>
@<End page@>
@}
@!************************************************
@O@<order.cgi@>@{@-
@<Begin CGI page@>
...
$v = $form{'@<Email FIELD@>'};
@<End CGI page@>
@}
@!************************************************
</PRE>
<P>This technique more or less completely eliminates
mismatch errors in form field names, for if any such error
is made, FunnelWeb will generate a "macro not defined"
error. All you have to do to benefit from this technique
is get into the habit of using it.
<P><BR><FONT SIZE="4"><STRONG>When Global Replace Fails</STRONG></FONT><BR>
<P>Many people who write HTML directly use nerve wracking
multi-file global replaces to perform the kind of web
parameterization that FunnelWeb makes so easy.
Unfortunately, these global replacements can go badly wrong
because the target text may be used in many different
contexts. In some cases, this approach fails completely.
<P>For example, suppose that you have to create a hundred
page web that has to be laced with two email addresses: a
"business" email address and a "personal" email address. No
problem so far. However, suppose that you haven't yet chosen
a business domain name and, as a result, at the current
time, the two email addresses are the same! If this were the
case, you would have to put your address throughout all the
pages and would LOSE the information of which were supposed
to be business addresses and which were supposed to be
personal ones.
<P>FunnelWeb solves this problem (and others like it)
completely by allowing you to define two macros one for each
context. For example:
<P>
<PRE>
@$@<Business EMAIL@>@M@{dave@@someisp.com.au@}
@$@<Personal EMAIL@>@M@{dave@@someisp.com.au@}
</PRE>
<P>These macros can then be used as appropriate. Later,
when the domain name comes through and the business address
changes, all that needs to be changed is a single definition:
<P>
<PRE>
@$@<Business EMAIL@>@M@{dave@@megacorp.com.au@}
@$@<Personal EMAIL@>@M@{dave@@someisp.com.au@}
</PRE>
<P>There is no need to perform a multi-file global replace
and evaluate the context of the use of each email address,
as the information was not lost when the web was originally
created, because of the two macros.
<P>This example is just one of many similar situations that
arise. By locating all the pages of your web in a single file
and allowing you to define macros for different purposes,
you can eliminate much of the time and danger of global
replacements.
<P>
<TABLE WIDTH="100%">
<TR>
<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>
<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>
<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>
</TR>
</TABLE>
<HR>
<FONT SIZE="2">
<A HREF="mailto:webmaster@ross.net">Webmaster</A>
<A HREF="copyright.html">Copyright © Ross N. Williams 1992,1999. All rights reserved.</A><BR>
</FONT>
</FONT>
</TD>
</TR>
</TABLE>
</BODY>
<!-- *********************************************************************** -->
<!-- End Of A FunnelWeb Manual Web Page (www.ross.net/funnelweb/) -->
<!-- *********************************************************************** -->
</HTML>
|