1 Introduction
2 Macros
3 Typesetting
4 Example
5 Hints
6 Examples
7 Webmaking

FunnelWeb Tutorial Manual

4 A Complete Example

To finish off the chapter, a complete example of a FunnelWeb input file is presented. Although unrealistically short, it gives a better idea of what a typical FunnelWeb .fw file looks like.

@!  Start of FunnelWeb Example .fw File  !

@t vskip 40 mm
@t title titlefont centre "Powers:"
@t title titlefont centre "An Example of"
@t title titlefont centre "A Short"
@t title titlefont centre "FunnelWeb .fw File"
@t vskip 10 mm
@t title smalltitlefont centre "by Ross Williams"
@t title smalltitlefont centre "26 January 1992"
@t vskip 20 mm
@t table_of_contents

@A@<FunnelWeb Example Program@>

This  program writes  out each  of the  first @{p@}
powers of  the first  @{n@} integers. These  constant
parameters are located  here so that they  are easy to

n : constant natural := 10;   -- [1,n] numbers?
p : constant natural :=  5;   -- [1,p]) powers?@}

@B Here is  the outline of the  program. This FunnelWeb
file  generates a single Ada output file  called
@{Power.ada@}. The main program consists  of a loop that
iterates once for each number to be written out.

@<Pull in packages@>

procedure example is
begin -- example
   for i in 1..n loop
      @<Write out the first p powers@>
   end loop;
end example;

@B In this section,  we pull in the packages that this
program  needs to run. In fact, all we need is the IO
package so that we can write out the results. To use the IO
package, we first of all need  to haul it in (@{with
text_io@}) and then we need to make all its identifiers
visible at the top level (@{use text_io@}).

@$@<Pull in packages@>@{with text_io; use text_io;@}

@B Here is  the bit that writes out  the first @{p@}
powers of  @{i@}. The power values  are  calculated
incrementally  in  @{ip@}  to  avoid  the  use  of  the
exponentiation operator.

@$@<Write out the first p powers@>@{@-
   ip : natural := 1;
   for power in 1..p loop
      put(natural'image(ip) & " ");
   end loop;

@!   End of FunnelWeb Example .fw File   !


FunnelWeb's functionality can be split into two parts: a macro preprocessor, and support for typesetting. The reader should be aware that the examples in this manual, constructed as they have been to demonstrate particular features of FunnelWeb, do not present a realistic picture of the best use of the tool. Only the example above comes close.

Prev Up Next

Webmaster    Copyright © Ross N. Williams 1992,1999. All rights reserved.