Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
FSearch Function
◄Summary► ◄Details► ◄Example► ◄Back►
Arguments
filename String expression representing the file to be
located
directories String expression representing the list of
directories to be searched
Returns
PathStr Directory and file name for the file if found;
otherwise, an empty string
Description
The FSearch function searches a list of directories for a file.
It returns a legal DOS path name for the file if found. An
unsuccessful search returns an empty string.
The filename argument is a legal DOS file name. It may specify a
directory, which is included in the search pattern and returned
with the file name.
The directories argument specifies the search list. Specify the list
with each full directory name separated by a semicolon (;) as
required by DOS. Shorthand directory notation '.' and '..' may be
used. The string cannot have embedded spaces.
FSearch looks first in the current directory and then sequentially
through the list of directories given in the directories argument.
It searches until the file is found or the list is exhausted.
FSearch returns a string of type PathStr, defined in the Dos unit.
The string contains a concatenation of the directory path and the
filename argument. The directory is the one in which the file was
found, and is as specified in the directories argument.
If the file is found in the current directory, only filename is
returned. If the file does not exist in any of the directories,
FSearch returns an empty string.
Expand the returned directory and file name to a fully qualified
DOS path name with the FExpand function.
To search the directories listed in the PATH environment variable,
use FSearch with a call to GetEnv:
result := FSearch( filename, GetEnv( 'PATH' ) );
Use the FindFirst and FindNext procedures to find all files
matching a pattern.