Microsoft KB Archive/58214

= Error 53 (&quot;File Not Found&quot;) Using FILES &quot;filespec&quot; Statement =

Article ID: 58214

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1
 * Microsoft GW-BASIC 3.2
 * Microsoft GW-BASIC 3.22
 * Microsoft GW-BASIC 3.23

-



This article was previously published under Q58214



SUMMARY
The FILES &quot;filespec&quot; statement prints the names of the files residing on the specified disk. However, the manual doesn't mention that if the &quot;filespec&quot; parameter does not describe any current filenames, an error 53 (&quot;File Not Found&quot;) is returned. Unless this error is trapped, program execution is halted.



MORE INFORMATION
When a FILES statement is used to list the files in a specific directory and the pattern that FILES is searching for does not exist, an error 53 (&quot;File Not Found&quot;) is returned.

If the error is not trapped by the program, the error message &quot;File Not Found&quot; is displayed in the interpreter environment. In executable programs, the message displayed is &quot;File Not Found In Module [Filename] at SEG:OFF,&quot; where SEG:OFF represents the segment and the offset from that segment of code where the error happened.

To avoid halting the program, the program needs only to trap the error 53 that is returned to the program. The program examples below demonstrate this, assuming that a file named ABC.XYZ does not exist on the root directory of drive C.

Example for Compiled Basics -- BASPROG.BAS
ON ERROR GOTO ErrorHandle FILES &quot;c:\abc.xyz&quot; END ErrorHandle: IF ERR = 53 THEN PRINT &quot;Error 53 was trapped. File not found.&quot; RESUME NEXT You can compile and link BASPROG.BAS as follows in QuickBasic 4.00, 4.00b, or 4.50, Basic compiler 6.00 or 6.00b, or Basic PDS 7.00: BC /x Basprog; LINK Basprog; Use QB /x Basprog in QuickBasic Versions 2.00, 2.01, 3.00.

Use BASCOM /x Basprog in QuickBasic Versions 1.00, 1.01, 1.02.

Example for GW-Basic Interpreter
10 ON ERROR GOTO 999 20 FILES &quot;c:\abc.xyz&quot; 30 END 999 IF ERR = 53 THEN PRINT &quot;Error 53 was trapped. File not found.&quot; 1000 RESUME NEXT

Additional query words: QuickBas BasicCom

Keywords: KB58214

-

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

© Microsoft Corporation. All rights reserved.