Include files

From CometWiki

Jump to: navigation, search

Include files

Include files are sections of an Internet Basic source program that are intended to be merged into main programs at compile time. In a way, include files are similar to subroutine source code libraries in other computer languages, and "include" libraries in some data base packages. In an application system, for example, a definition of the fields and format for a particular data file will be used in all of the programs reading and/or writing that file. It is therefore more practical to include the field and format definitions in a single source file (called an include file). This single source file may then be merged into the object program at compilation time.

The following diagram shows how include files are used. The main source program is written with the assumption that various include files exist. These include files could contain data definitions, formatting commands, processing routines, etc. When the main program is compiled, the include files are merged into the main program. The resulting object program contains the definitions, format commands, and instructions from the main program and all of the include files called.


  -----------------------                ---------------------
  |   Main source file  |                | Include file 1    |
  |                     |                |                   |
  |                     |<---------------|                   |
  |                     |                |                   |
  |                     |                |                   |
  |                     |                ---------------------
  |                     |
  |                     |                ------------------
  |                     |                | Include file 2 |
  |                     |                |                |
  |                     |<---------------|                |
  |                     |                |                |
  |                     |                |                |
  -----------------------                ------------------

Include files are created the same way as source files, namely with a text editor/word processor, or with the Comet editor program. To merge a include file into the main object program, you must use an INCLUDE directive in the main source program.

Personal tools