Contents Previous Next Subchapters

Explicit Inclusion of Commands or Functions from a File
Syntax include file_name
See Also auto_include , debugger include
Menu Command Command | Include . . .

Description
Reads commands from the file specified by file_name .

Including From the Command Line
The include directive executes a set of previously written O-Matrix instructions. If the file temp.oms contains
     I = {[1, 0], [0, 1]}
     print I
and, in the Command window, you enter
     include temp.oms
O-Matrix will respond
     {
     [ 1 , 0 ]
     [ 0 , 1 ]
     }
(If temp.oms does not exist, this example will result in an error message.)

Including From a File
An included file can execute other files using the include directive. For example, if the text file TEMP2.OMS contains
     clear
     print "Hello World!"
     include temp.oms
     print "Goodbye World!"
and, in the Command window, you enter
     include temp2.oms
O-Matrix will respond
     Hello World!
     {
     [ 1 , 0 ]
     [ 0 , 1 ]
     }
     Goodbye World!
O-Matrix will ignore any attempt by an included file to execute a file that has already been included (unless a clear was entered after the previous include). A previously included file, however, can be included at the O> prompt.

Searching For The File
If file_name begins with a disk drive specification; i.e., if its second character is a :, no path is added to the file specification when searching for it.

If file_name begins with the root directory, i.e., if its first character is a \, the root directory on the current disk is searched for the specified file. (The current disk corresponds to the first letter returned by the cwd function.)

If the first character in file_name is not a \ and the second character is not a :, the directories specified by the current O-Matrix path setting will be searched in order for an occurrence of the specified file. The current directory is searched after the search path for the specified file. If the file does not exist in any of the specified locations, and error message occurs.

Reference
Files can be automatically included .

The include command is not available in Mlmode .

A list of all the currently included files can be obtained using the Debugger include command.

The syntax mlmode file_name can be used to execute a file that is written using the Mlmode language.

Automatic includes differ from the include command in that the current directory is searched before the search path for automatic includes. Thus the include command should be used by library files that want to reference another file in the library and not in the current working directory.