KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q30608: In QB.EXE, Save with "Too Many Files" Erases Source File

Article: Q30608
Product(s): See article
Version(s): 4.00 4.00b
Operating System(s): MS-DOS
Keyword(s): ENDUSER | buglist4.00 buglist4.00b fixlist4.50 B_BasicCom | mspl13_basic
Last Modified: 21-NOV-1988

When running in the QB.EXE editor, if a program opens all available
DOS file handles and an error message such as "Division by Zero"
appears, a subsequent Save command in the editor erases the file and
the message "Too Many Files" is displayed.

Microsoft has confirmed this to be a problem in QuickBASIC Versions
4.00 and 4.00b, and in the QuickBASIC that accompanies the Microsoft
BASIC Compiler Versions 6.00 and 6.00b for MS-DOS and OS/2
(buglist6.00, buglist6.00b). This problem was corrected in QuickBASIC
Version 4.50.

This problem does not occur in QuickBASIC Versions 2.00, 2.01, and
3.00.

You can work around this problem by doing either of the following two
things:

1. Issuing a CLOSE from the immediate window to free file handles
   before saving the program

2. Performing a Selected Print from the file menu (ALT+F+P) before
   saving.

Because DOS preallocates five file handles, only 15 are available for
program use. (This occurs when you boot your DOS with the FILES=20
statement in your DOS CONFIG.SYS file.)

If a program terminates abnormally, these file handles may stay
allocated to QuickBASIC, as in the example program below. Performing
Shell or Save from the File menu in QB.EXE then fails when attempting
to open the twenty-first file handle, as in the following example :

1. Executing a Shell command from the File menu displays the following
   message:

      "Illegal Function Call"

2. Executing a Save command from the File menu displays the following
   message and erases the file:

      "Too Many Files"

Please note that Shell can be used as a test to determine if you have
run out of file handles. If Shell is successful, you can Save freely
without deleting the file.

The following steps reproduce the problem:

1. Boot with FILES=20 in your DOS CONFIG.SYS file.

2. Run the following program (a "Divide By Zero" error message
   appears):

   FOR k = 1 TO 15
      OPEN "file" + STR$(k) FOR RANDOM AS #k
   NEXT k
   m = 0
   PRINT 1 / m

3. Try to Save from the File menu in QB.EXE. A "Too Many Files" error
   message will appear.

4. The program file is now erased and cannot be reopened in QB.EXE.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.