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.
FINDFILE.PAS
◄Example► ◄Contents► ◄Index► ◄Back►
PROGRAM findfile;
{ FINDFILE.PAS demonstrates the following procedures:
Delete FExpand FSearch FSplit Pos
}
USES
Dos;
CONST
program_name = 'FINDFILE ';
program_desc = 'searches directories for a specified file.';
VAR
filename : STRING;
search_path : STRING;
found_file : pathstr;
full_path : pathstr;
dir : DirStr;
fname : NameStr;
exten : ExtStr;
BEGIN
Writeln( program_name, program_desc );
Writeln;
Write( 'Name of file to find: ' );
Readln( filename );
Writeln( 'Enter directories to search, separated by semicolons: ' );
Readln( search_path );
{ Remove embedded spaces. }
WHILE (Pos( ' ', search_path ) > 0) DO
Delete( search_path, Pos( ' ', search_path ), 1 );
{ Search. }
found_file := FSearch( filename, search_path );
IF (found_file = '') THEN
Writeln( filename, ' not found.' )
ELSE
BEGIN
full_path := FExpand( found_file );
FSplit( full_path, dir, fname, exten );
Writeln( 'File found first in:' );
Writeln( 'Drive/directory : ', dir );
Writeln( 'File name : ', fname );
Writeln( 'Extension : ', exten );
END;
END.