Directory, Display Files, List Files

Three nearly synonymous commands to list files meeting specified file skeletons, similar to the DOS DIR equivalent, but with Visual FoxPro-specific extensions.
Usage
DIRECTORY | DISPLAY FILES | LIST FILES
      [ ON cDriveLtr ] 
      [ [ LIKE ] [ cPath ] [ cFileSkeleton ] ]
      [ TO PRINTER [ PROMPT ] | TO FILE cFileName [ ADDITIVE ] ]
Following the rule in Visual FoxPro that every rule has an exception (including this one), the DIRECTORY command is one of the few (perhaps the only) that can be abbreviated to three letters (DIR) rather than the usual (but not always true) four.If no file skeleton is specified, Visual FoxPro lists only DBF files, and includes information on the number of records in the file, the file size, and also a comment if the file is a FoxBase 2-style file. If a skeleton is supplied, only the names of the specified files are listed, similar to the wide-listing format of the DOS DIR command.Although the command has the same name, this is not DOS. Note that the syntax above has the drive letter and the path as separate arguments. It appears that everything after the first letter in the drive parameter is ignored. DIR D:\EXAMPLES is likely to give you different results than DIR ON D\EXAMPLES\. This can be confusing. Our advice: Skip the ON parameter, forget passing the LIKE optional keyword, and pass the path just like DOS, as in DIR D:\EXAMPLES or DIR *.PRG

Unlike all the other DISPLAY/LIST commands, the FILES list lacks a NOCONSOLE option. In VFP 7, this bug is worse than ever because the Quick Info for the command shows a NOCONSOLE clause, but it doesn't work. Worse, if you omit the path and file skeleton, but include NOCONSOLE, the command looks for tables called NOCONSOLE.


The output options, TO PRINTER and TO FILE, work similarly to the remainder of the DISPLAY and LIST commands. The DISPLAY and LIST versions have the usual differences. DIR works like DISPLAY FILES.

Example

DISPLAY FILES ON C LIKE \VFP\SAMPLES\MAINSAMP\DATA  && this is 
DIR C:\VFP\SAMPLES\MAINSAMP\DATA           && the same as this

See Also

ADir(), Directory(), Display and List, File()


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .