Description
filename is the type identifier for a built-in string type which is the recommended type for variables used to store file and directory/folder names.
Example
Below is a simple program that lists the names of all the files in the current directory and uses variables of type filename to store the names of the files.
program listfiles(output);
var
d : dir;
filename : string;
function IsDir(name : filename) : boolean;
var
mode : integer;
begin
getfilemode(name, mode);
IsDir := (mode and dir_bit) <> 0;
end;
begin
opendir(d, '.'); { Open current directory }
repeat
readdir(d, filename); { Get next file in directory }
{ if the next file exists and it is NOT a directory then list it }
if (filename <> '') and (not IsDir(filename)) then
writeln(filename);
until filename = '';
closedir(d) { Close directory }
end.
Portability
Operating Systems: All
Standard Pascal: No