Q(uick)BASIC Statement: FILES
Quick View
FILES
A statement that interfaces with DOS to print the names of files residing on the specified disk
Worth knowing
Useful and cross-version information about the programming environments of QBasic and QuickBasic.
Syntax
- CHDIR pathname$
- MKDIR pathname$
- RMDIR pathname$
- FILES [filespec$]
Description/Parameter(s)
CHDIR changes a drive's default directory. MKDIR creates a subdirectory. RMDIR removes a subdirectory. FILES displays the contents of the current directory or a specified directory.
pathname$ | The path of the new default directory, subdirectory to create, or subdirectory to remove. |
filespec$ | A filename or path (may include a drive and DOS wildcard characters). If you don't specify a filespec$, FILES displays all files in the current directory. |
Example
MKDIR "C:\TEMP\TEST"
CHDIR "C:\TEMP"
FILES
RMDIR "TEST"
Syntax
- FILES [filespec]
Description/Parameter(s)
The filespec is a string variable or constant that includes either a file name or a path name, and an optional device designation.
If you omit filespec, the FILES statement lists all the files in the current directory. You may use the DOS wild card characters--question marks (?) or asterisks (*). A question mark matches any single character in the file name or extension. An asterisk matches one or more characters starting at that position.
If you use a filespec without an explicit path, the current directory is the default.
Note that, regardless of the path name contained in filespec, the header printed by FILES is always the current directory.
Example
The following statements illustrate the use of FILES.
Note: Execution halts if you try to run this example without a disk in drive B, or if the specified files cannot be found.
FILES 'Shows all files on the current directory.
FILES "*.BAS" 'Shows all files with the extension .BAS.
FILES "B:*.*" 'Shows all files on drive B.
FILES "B:" 'Equivalent to "B:*.*".
FILES "TEST?.BAS" 'Shows all five-letter files whose names
'start with "TEST" and end with the .BAS
'extension.
FILES "SALES" 'If SALES is a directory, this statement
'displays all files in SALES; if SALES is
'a file in the current directory, this
'statement displays the name SALES.
See also:
Syntax
- FILES (filespec$)
Description/Parameter(s)
Usage Notes
- You may use the DOS wildcard characters--question marks (?) or asterisks (*). A question mark matches any single character in the filename or extension. An asterisk matches one or more characters starting at that position.
- If you use the argument filespec$ without an explicit path, the current directory is the default.
Example
This example uses the FILES statement to print the names of the files residing on a specified disk.
Note: Execution halts if you try to run this example without a disk in drive B or if the specified files cannot be found.
FILES 'Shows all files on the current directory.
FILES "*.BAS" 'Shows all files with the extension .BAS.
FILES "B:*.*" 'Shows all files on drive B.
FILES "B:" 'Equivalent to "B:*.*".
FILES "TEST?.BAS" 'Shows all five-letter files whose names
'start with "TEST" and end with the .BAS
'extension.
FILES "SALES\" 'If SALES is a directory, this statement
'displays all files in SALES.