Introduction

Language Structure

IB Statements

File System

Comet 32 Runtime

Index

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 Internet Basic source program.

The usefile-name parameter is the name of the Internet Basic usefile to be merged. This name must be enclosed in matching quotation marks (single or double). The usefile may be a text file or a Comet Editor (CED) 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 Internet Basic 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: This 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

Internet Basic source statement
LENGTH 1 & LOCAL OPTION$
LENGTH 5 & LOCAL FLAG$
USE "CUST"
.
.
.

Usefile named "CUST"

Internet Basic 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$