::REQUIRES

The ::REQUIRES directive specifies that the program requires access to the classes and objects of the Rexx program programname.

>>-::REQUIRES--"programname"--;--------------------------------><

All public classes and routines defined in the named program are made available to the executing program. The programname is a literal string or a symbol that is taken as a constant. The string or symbol programname can be any string or symbol that is valid as the target of a CALL instruction. The program programname is called as an external routine with no arguments. The main program code, which precedes the first directive instruction, is run.

On Linux/Unix when the interpreter searches for the programname it follows the following rules:

  1. If the programname is a quoted string then no conversion of the programname is performed prior to the search for the file.

  2. If the programname is unquoted then it is first converted to all uppercase and then the search is performed. If the programname is not found then it is converted to all lowercase and searched for again. A mixed case programname search is NOT performed.

On Windows the filesystems are essentially caseless so no conversions are necessary.

Any ::REQUIRES directive must precede all ::CLASS, ::METHOD, and ::ROUTINE directives. The order of ::REQUIRES directives determines the search order for classes and routines defined in the named programs.

If any Rexx code preceeds the first directive in programname then that code is executed at the time the ::REQUIRES is processed by the interpreter. This is also prior to the beginning of the main Rexx program

The following example illustrates that two programs, ProgramA and ProgramB, can both access classes and routines that another program, ProgramC, contains. (The code at the beginning of ProgramC runs prior to the start of the main Rexx program.)

The language processor uses local routine definitions within a program in preference to routines of the same name accessed through ::REQUIRES directives. Local class definitions within a program override classes of the same name in other programs accessed through ::REQUIRES directives.

Another directive, or the end of the program, must follow a ::REQUIRES directive. Only null clauses can appear between them.