KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q37339: A Single-Precision Number as a File Number Causes "Overflow"

Article: Q37339
Product(s): See article
Version(s): 6.00 6.00b | 6.00 6.00b
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | B_QuickBas | mspl13_basic
Last Modified: 2-FEB-1990

A program compiled with Microsoft BASIC Compiler Version 6.00 or
6.00b, or QuickBASIC Version 4.00 or 4.00b, generates an "Overflow"
error message if you are using a single-precision variable as the
number of a file to be opened.

This behavior does not occur in Microsoft QuickBASIC Version 4.50 for
MS-DOS or Microsoft BASIC Professional Development System (PDS)
Version 7.00 for MS-DOS and MS OS/2.

The following sample code demonstrates the problem. If the file number
"F" is redefined as an integer, the program works correctly. The
program also can be forced to work correctly using any of the
following alternatives:

1. By compiling with the /o, /d, /v, or /x compiler-option switches

2. By putting line numbers on affected lines

3. By deleting a few lines of code in the subroutine

Earlier versions of Microsoft QuickBASIC do not have this problem.

The following is an example:

   DIM SHARED f9$(22, 9), id$(9), size%(9), fdr$(9)
   CLS
   f = 1
   fi$ = "FILENAME.DAT"
   CALL OPEN.ISAM(f, fi$)
   END

   SUB OPEN.ISAM (f, fid$) STATIC
        OPEN "r", f, fid$, 256
           FIELD #f, 256 AS f9$
        fdr$(f) = SPACE$(256)
           size%(f) = LOF(f) / 256
           id$(f) = fid$
   END SUB

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.