Operators and Keywords

Function List:


Built-in Function: c = exist (name)
Built-in Function: c = exist (name, type)

Check for the existence of name as a variable, function, file, directory, or class.

The return code c is one of


name is a variable.


name is an absolute file name, an ordinary file in Octave’s path, or (after appending ‘.m’) a function file in Octave’s path.


name is a ‘.oct’ or ‘.mex’ file in Octave’s path.


name is a built-in function.


name is a directory.


name is a function not associated with a file (entered on the command line).


name does not exist.

If the optional argument type is supplied, check only for symbols of the specified type. Valid types are


Check only for variables.


Check only for built-in functions.


Check only for directories.


Check only for files and directories.


Check only for classes. (Note: This option is accepted, but not currently implemented)

If no type is given, and there are multiple possible matches for name, exist will return a code according to the following priority list: variable, built-in function, oct-file, directory, file, class.

exist returns 2 if a regular file called name is present in Octave’s search path. If you want information about other types of files not on the search path you should use some combination of the functions file_in_path and stat instead.

See also: file_in_loadpath, file_in_path, dir_in_loadpath, stat.

Package: octave