Microsoft KB Archive/32724

= Using FILES$ or FILES to Display Filename or Disk Directory =

Article ID: 32724

Article Last Modified on 11/21/2006



This article was previously published under Q32724



SUMMARY
The FILES$ function and the FILES statement cannot display files based on the letters in the filenames. Wild cards in filenames, such as the &quot;*&quot; or &quot;?&quot; symbols supported in MS-DOS file commands, are not supported in BASIC for the Macintosh. (For example, the MS-DOS command DIR *.DOC displays all files with .DOC in the name; however, BASIC for the Macintosh does not have a similar feature.)

Although the FILES statement can send a disk directory to the screen, there is no easy feature to send a disk directory to a file or array, except through calls to Toolbox routines. (For more information, query on the word &quot;HFSDispatch&quot;.)

Note that the CHDIR command affects the file folder (subdirectory) displayed by the FILES statement, but CHDIR does NOT affect the file folder displayed by the FILES$(1) function. FILES$(1) always displays the files in the folder where the source file is located (if run in the interpreter), or the files in the folder where the compiled program apl file is located (if run from a compiled program). The FILES$(1) window lets you manually look through other folders with the mouse.

This information applies to Microsoft QuickBASIC Version 1.00, Microsoft BASIC Compiler Version 1.00, and Microsoft BASIC Interpreter Version 3.00 for the Apple Macintosh.



MORE INFORMATION
The FILES$(n) function (where n can be 0 or 1) and the FILES statement offer different capabilities.

The FILES$(n) function can be used to display all files of a certain type and to return one selected filename in a string variable. For example, x$=FILES$(1,&quot;TEXT&quot;) displays a dialog box listing all files of type TEXT. The following program displays a scroll box containing all files of type APPL (applications) and TEXT: x$=FILES$(1,&quot;TEXTAPPL&quot;) PRINT X$  ' Prints the name of the one selected file.

The FILES statement displays on the screen the filenames in the &quot;current&quot; folder and drive. On a 400K disk, all files will display regardless of their folders; however, on 800K or hard disks, only the files in the current folder will display. (The current folder is defined as the folder in which the BASIC interpreter or compiled program is located.)

BASIC's current folder can be changed with the CHDIR command. For example, the following program changes the current folder on the disk called &quot;HD 20&quot; to a folder called &quot;System,&quot; and the FILES statement displays the files in that folder: CHDIR &quot;HD 20:System:&quot; FILES A colon is required after both the disk name and folder name, as shown above.

The CHDIR statement affects the folder displayed by the FILES statement, but NOT the folder displayed by default by the FILES$(1) function. The FILES$(1) function displays a scrolling dialog box which lets you manually change folders (subdirectories) with the mouse.

Additional query words: MQuickB

Keywords: KB32724

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.