Introduction

Language Structure

IB Statements

File System

Comet 32 Runtime

Index

INCLUDE directive

Syntax: INCLUDE include-filename [,directory-name] [,starting-edit-line-number]
Discussion: The INCLUDE statement is a compiler directive. As such, it causes an action to occur when the program is compiled, not when the program is executed. The INCLUDE directive can appear anywhere in an Internet Basic source program.

The include-filename parameter is the name of the Internet Basic include file to be merged. This name must be enclosed in matching quotation marks (single or double). The include file may be a text file or Comet Editor (CED) file.

The directory-name parameter (optional) represents the name of the Comet directory where the include file is stored.

Legacy application
If the include file is a Comet Editor file, a single include file may actually contain multiple segments of code to be merged into the main program. In these cases, the INCLUDE directive must specify the starting location in the include file itself (otherwise the Internet Basic compiler will start at the beginning of the include file). The starting-edit-line-number (optional) is the Comet editor line number in the include file where the merging is to start.

Note: If you include multiple program segments in a single include file, you must conclude each segment with the END statement or ENDUSE directive. This way, the compiler will merge lines up to the END or ENDUSE directive, but not beyond.

The statements in the include file will be merged into the program section where the INCLUDE directive appears. Therefore, the include file must contain the same kind of statements (e.g., Data Division, I/O Format Division, or Procedure Division) as the section of the program where the INCLUDE directive appears.

Include files may be nested to two levels. This means that an include file may contain another INCLUDE directive. In this case, the secondary level program lines will be merged into the primary include file, and those lines will be merged into the main object program.

History: The INCLUDE statement was added to the language in Build 292 as a synonym for the USE directive.
Example: The following example shows a main program that merges a single include file into the resulting object program at compile time. The include file is a text file named "CUST."

Main program

   LENGTH 1 & LOCAL OPTION$
   LENGTH 5 & LOCAL FLAG$
   INCLUDE "CUST.INC"
   .
   .
   .

Include file named "CUST.INC"

   LENGTH 5 & LOCAL CUSTNUM$
   LENGTH 30
   LOCAL CUSTNAME$,ADDRESS$
   LENGTH 15 & LOCAL CITY$
   LENGTH 2 & LOCAL STATE$
   LENGTH 10 & LOCAL ZIPCODE$
   LENGTH 20 & LOCAL CONTACT$
   LENGTH 20 & LOCAL TITLE$
   LENGTH 12 & LOCAL PHONE$
   !
   1000 FORMAT_
        CUSTNUM$;_
        CUSTNAME$;_
        ADDRESS$;_
        CITY$;_
        ZIPCODE$;_
        CONTACT$;_
        TITLE$;_
        PHONE$