| 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>2.8 Include Files</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">2.8 Include Files</FONT><BR> |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
<P>FunnelWeb provides a nested include file facility that |
| 106 |
can be used for a number of purposes. When FunnelWeb runs |
| 107 |
into a single line containing the special sequence |
| 108 |
<SAMP>@i</SAMP> followed by a blank, followed by a |
| 109 |
file name, it reads in the designated file and replaces the |
| 110 |
line containing the command (including the end of line |
| 111 |
marker at the end of the line) with the entire contents of |
| 112 |
the designated file. For example, if there was a file called |
| 113 |
<SAMP>camera.txt</SAMP> containing the two |
| 114 |
lines: |
| 115 |
|
| 116 |
<P> |
| 117 |
<PRE> |
| 118 |
'Cos I shoot with a camera instead of a gun. |
| 119 |
The animals flock to be petted and fed, |
| 120 |
</PRE> |
| 121 |
|
| 122 |
<P>and another file called <SAMP>poem.fw</SAMP> |
| 123 |
containing the following four lines |
| 124 |
|
| 125 |
<P> |
| 126 |
<PRE> |
| 127 |
I like to go shooting, it's a whole lot of fun, |
| 128 |
@i camera.txt |
| 129 |
Cos they know my camera isn't loaded with lead. |
| 130 |
- RNW, 04-Jan-1991. |
| 131 |
</PRE> |
| 132 |
|
| 133 |
<P>Then, if FunnelWeb were to process <SAMP>poem.fw</SAMP>, |
| 134 |
the result would be as if FunnelWeb had read in: |
| 135 |
|
| 136 |
<P> |
| 137 |
<PRE> |
| 138 |
I like to go shooting, it's a whole lot of fun, |
| 139 |
'Cos I shoot with a camera instead of a gun. |
| 140 |
The animals flock to be petted and fed, |
| 141 |
'Cos they know my camera isn't loaded with lead. |
| 142 |
- RNW, 04-Jan-1991. |
| 143 |
</PRE> |
| 144 |
|
| 145 |
<P>FunnelWeb expands include files before it starts |
| 146 |
scanning and parsing the included text. The result is that |
| 147 |
include files can contain anything that can be found in a |
| 148 |
FunnelWeb file. The following example illustrates the level |
| 149 |
at which the include mechanism operates. If |
| 150 |
<SAMP>main.fw</SAMP> contains |
| 151 |
|
| 152 |
<P> |
| 153 |
<PRE> |
| 154 |
@O@<output.dat@>==@{@- |
| 155 |
@i inc.fw |
| 156 |
This is the text of the sloth macro. |
| 157 |
@} |
| 158 |
</PRE> |
| 159 |
|
| 160 |
<P>and inc.fw contains |
| 161 |
|
| 162 |
<P> |
| 163 |
<PRE> |
| 164 |
@<Sloth@> |
| 165 |
@} |
| 166 |
|
| 167 |
@$@<Sloth@>==@{@- |
| 168 |
</PRE> |
| 169 |
|
| 170 |
<P>Then if FunnelWeb were applied to <SAMP>main.fw</SAMP>, it would see: |
| 171 |
|
| 172 |
<P> |
| 173 |
<PRE> |
| 174 |
@O@<output.dat@>==@{@- |
| 175 |
@<Sloth@> |
| 176 |
@} |
| 177 |
|
| 178 |
@$@<Sloth@>==@{@- |
| 179 |
This is the text of the sloth macro. |
| 180 |
@} |
| 181 |
</PRE> |
| 182 |
|
| 183 |
<P>which it would process in the normal manner. The only |
| 184 |
special sequence processing that takes place at a level |
| 185 |
lower than include files is the processing of the |
| 186 |
<SAMP><special>=<newspecial></SAMP> |
| 187 |
sequence which changes the special character. |
| 188 |
|
| 189 |
<P>A few other facts about include files are worth |
| 190 |
mentioning here. Include files inherit the directory |
| 191 |
specification supplied using the <SAMP>+I</SAMP> command line |
| 192 |
option. The special character is saved at the start of each |
| 193 |
include file and restored to its previous value at the end |
| 194 |
of each include file. Include files can be nested up to ten |
| 195 |
levels. Recursive included files will always cause an infinite recursion |
| 196 |
as there is no bottoming out mechanism available. Include |
| 197 |
files must contain an integer number of lines (i.e. the |
| 198 |
last line must be terminated with an end of line marker). |
| 199 |
Once FunnelWeb has seen "<TT>@i </TT>" at the start of a |
| 200 |
line, it will grab the rest of the line raw and treat it as |
| 201 |
a file name. There is no place on the line for things like |
| 202 |
FunnelWeb comments (see later) or extraneous text. |
| 203 |
|
| 204 |
<P>Include files can be used for many purposes, but are |
| 205 |
particularly useful for hauling in macro |
| 206 |
libraries. |
| 207 |
|
| 208 |
|
| 209 |
<P> |
| 210 |
<TABLE WIDTH="100%"> |
| 211 |
<TR> |
| 212 |
<TD ALIGN="left" VALIGN="bottom"><A HREF="macro_expansion.html"><IMG SRC="binary/fw_left.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Prev"></A></TD> |
| 213 |
<TD ALIGN="center" VALIGN="bottom"><A HREF="macro.html"><IMG SRC="binary/fw_up.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Up"></A></TD> |
| 214 |
<TD ALIGN="right" VALIGN="bottom"><A HREF="macro.html"><IMG SRC="binary/fw_up.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Up"></A></TD> |
| 215 |
</TR> |
| 216 |
</TABLE> |
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
<HR> |
| 221 |
<FONT SIZE="2"> |
| 222 |
<A HREF="mailto:[email protected]">Webmaster</A> |
| 223 |
<A HREF="copyright.html">Copyright © Ross N. Williams 1992,1999. All rights reserved.</A><BR> |
| 224 |
</FONT> |
| 225 |
|
| 226 |
</FONT> |
| 227 |
</TD> |
| 228 |
</TR> |
| 229 |
</TABLE> |
| 230 |
|
| 231 |
|
| 232 |
</BODY> |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
</HTML> |