# Including header files

## Contents

- Procedure prototypes
- Const.oph

OPL allows you to include header files which may include definitions of procedure prototypes and constants, but not procedures themselves. Constants and procedure prototypes may also be declared at the top of modules themselves, although it is tidier to put them into a header file. Indeed, including a file is logically identical to replacing the `INCLUDE` statement by the file’s contents.

A header file is included in a module using the `INCLUDE` command at the beginning of the module, outside any procedure. For example,

        INCLUDE "Header.oph"

The filename of the header may or may not include a path. If it does include a path, then OPL will only scan the specified folder for the file. However, the default path for `INCLUDE` is `\System\Opl\`, so when `INCLUDE` is called without specifying a path, OPL looks for the file firstly in the current folder and then in `\System\Opl\` in all drives from `Y:` to `A:` and then in `Z:`.

Commonly the statement,

        DECLARE EXTERNAL

will follow the `INCLUDE` declaration. `DECLARE EXTERNAL` causes the translator to report ‘`Undefined externals`’ errors if any variables or procedures are used before they are declared, rather than leaving this until runtime.

## Procedure prototypes

Procedure prototypes are declared with the command `EXTERNAL`. For example,

        EXTERNAL Proc1:

A prototype is a declaration of the name of the procedure along with the arguments it takes. This amounts to the same as `PROC` declaration with the `PROC` keyword, which declares the start of a procedure, omitted. The procedure may then be referred to before it is defined when the `DECLARE EXTERNAL` statement has been made. As well as reporting ‘Undefined externals’ error at translate-time, the other advantage of using the `DECLARE EXTERNAL` and `EXTERNAL` statements is that it allows parameter type-checking to be performed at translate-time rather than at runtime, and also provides the necessary information for the translator to coerce numeric argument types, thus avoiding ‘Type violation’ errors at runtime. Hence a ‘`Type violation`’ error does not result in the following example, even though a `&` does not precede the 2 passed to the procedure `two:()`,

        DECLARE EXTERNAL
        EXTERNAL two:(long&)

        PROC one:
              two:(2)
        ENDP

        PROC two:(long&)
              ...
        ENDP

The same coercion occurs as when calling the built-in keywords.

## Const.oph

`Const.oph` is the standard header file in the ROM. It provides many of the standard constant declarations required for effective and maintainable OPL programming. For convenient reference, the contents `Const.oph` is reproduced in full in Listing of Const.oph. This and other files stored in the ROM (for example, the OPX header files) may be created in RAM by using the ‘Create standard files’ option in the ‘Tools’ menu in the Program editor.

See also Keyword Reference.