4

The actual includefile looks like this:

begin

writeln ('Hello, world.')

end.

In this example, the include file contains the entire program. In reality, an include file probably contains a set of variable or procedure declarations. include files are often used when a set of declarations needs to be shared among a number of programs.

However, suppose your program is very large and takes a long time to compile. Using include files may make editing more convenient, but when you make a change in one part of your program, you still must recompile the entire program. As another example, suppose you want to be able to share compiled code with other people, but for reasons of security or convenience, do not want to share the source code.

Both of these problems are solved by separately compiled units, generally called units. A unit is a part of a program stored in its own file and linked with the rest of the program after compilation.

Using Program Units and Module Units

There are two kinds of units:

Program unit—This unit looks like any program. It begins with a program header and contains the main program.

Here is an example:

program program_unit (output); procedure say_hello; extern; begin

say_hello

end.

68

Pascal 4.0 User’s Guide