KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q21311: How DEFINT, DEFSNG, DEFDBL Affect Type of DEF FN Function

Article: Q21311
Product(s): See article
Version(s): 5.35 5.36 6.00 6.00b 7.00 7.10 | 6.00 6.00b 7.00 7.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | B_QuickBas B_BasicInt | mspl13_basic
Last Modified: 17-JAN-1991

This article discusses the default type declaration of DEF FN
user-defined functions in Microsoft BASIC.

The DEFINT, DEFLNG, DEFDBL, and DEFSNG statements affect the first
letter of the variable part of a DEF FN function name, and not the FN
part of the function name. This information applies to all Microsoft
BASIC compilers and interpreters for MS-DOS, MS OS/2, Macintosh, and
CP/M-80.

Microsoft BASIC Compiler versions 6.00 and later, and QuickBASIC
versions 4.00 and later for the IBM PC, introduced the DEFLNG
statement for long integer declaration, which also behaves this way.

Example
-------

The following program prints 1.2 (a noninteger):

   10 DEFINT F   ' DEFINT F doesn't affect the DEF FN below.
   20 DEF FNAB=1.2
   30 PRINT FNAB

The following program prints 1 (truncated to an integer):

   10 DEFINT A   ' DEFINT A does affect the DEF FN below.
   20 DEF FNAB=1.2
   30 PRINT FNAB

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.