| Introduction | MTB Statements | File System | Compiler | Applications | Reference Guide | Index |
| Overview | Creating MTB Source Programs | Compiling MTB Programs | Compiler Directives | Special Characters |
| 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 MTB source program.
The include-filename parameter is the name of the MTB include file to be merged. This name must be enclosed in matching quotation marks (single or double). The include file may be a Comet Editor (CED) file or a text file. The directory-name parameter (optional) represents the name of the Comet directory where the include file is stored. 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 MTB 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 1: |
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 Comet Editor file named "CUST." The editor line
numbers are shown for reference purposes only.
Main program Editor line number MTB source statement ================================= 100 LENGTH 1 & LOCAL OPTION$ 200 LENGTH 5 & LOCAL FLAG$ 300 INCLUDE "CUST" 400 . 500 . 600 . Include file named "CUST" Editor line number MTB source statement =================================== 1000 LENGTH 5 & LOCAL CUSTNUM$ 1100 LENGTH 30 1200 LOCAL CUSTNAME$,ADDRESS$ 1300 LENGTH 15 & LOCAL CITY$ 1400 LENGTH 2 & LOCAL STATE$ 1500 LENGTH 10 & LOCAL ZIPCODE$ 1600 LENGTH 20 & LOCAL CONTACT$ 1700 LENGTH 20 & LOCAL TITLE$ 1800 LENGTH 12 & LOCAL PHONE$ 1900 ! 2000 1000 FORMAT_ 2100 CUSTNUM$;_ 2200 CUSTNAME$;_ 2300 ADDRESS$;_ 2400 CITY$;_ 2500 ZIPCODE$;_ 2600 CONTACT$;_ 2700 TITLE$;_ 2800 PHONE$ |
| Example 2: |
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
MTB source statement
========================
LENGTH 1 & LOCAL OPTION$
LENGTH 5 & LOCAL FLAG$
INCLUDE "CUST"
.
.
.
Include file named "CUST"
MTB source statement
===================================
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$
|