Introduction MTB Statements File System Compiler Applications Reference Guide Index

Overview Creating MTB Source Programs Compiling MTB Programs Compiler Directives Special Characters

USE directive

Syntax: USE usefile-name [,directory-name] [,starting-edit-line-number]
Discussion: The USE 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 USE directive can appear anywhere in an MTB source program.

The usefile-name parameter is the name of the MTB usefile to be merged. This name must be enclosed in matching quotation marks (single or double). The usefile 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 usefile is stored.

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

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

The statements in the usefile will be merged into the program section where the USE directive appears. Therefore, the usefile 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 USE directive appears.

Usefiles may be nested to two levels. This means that a usefile may contain another USE directive. In this case, the secondary level program lines will be merged into the primary usefile, and those lines will be merged into the main object program.

History:
  • Starting with Comet98/Comet2000 Build 292, the INCLUDE directive may be used as a synonym for USE.

  • Prior to Comet version 504.207, the starting-edit-line-number value could be expressed as a Comet editor line number, without including quotation marks. However, if you included quotation marks, the compiler would not recognize the command. This was corrected in Comet version 504.207. The compiler now recognizes both forms, as follows:
        USE usefile-name,,starting-edit-line-number
        USE usefile-name,,"starting-edit-line-number"
    
    Please note that the second form must include the appropriate number of leading blanks before the editor line number. For example, if the starting-edit-line-number is 1000, the string should include 3 leading blanks, as follows:
        USE usefile-name,,"   1000"
    
Example 1: The following example shows a main program that merges a single usefile into the resulting object program at compile time. The usefile 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      USE "CUST"
400      .
500      .
600      .

Usefile 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 usefile into the resulting object program at compile time. The usefile is a text file named "CUST."
   
Main program

MTB source statement
========================
LENGTH 1 & LOCAL OPTION$
LENGTH 5 & LOCAL FLAG$
USE "CUST"
.
.
.

Usefile 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$