KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q39581: Can’t Define SUB/FUNCTION in INCLUDE File

Article: Q39581
Product(s): See article
Version(s): 6.00 6.00b 7.00 | 6.00 6.00b 7.00
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | B_QuickBas SR# S881209-27 | mspl13_basic
Last Modified: 1-FEB-1990

The command line compiler BC.EXE fails to flag the error if you put a
procedure definition (SUB...END SUB or FUNCTION...END FUNCTION) into
an INCLUDE file. The program compiles, LINKs, and runs without error.

QB.EXE, and QBX.EXE included with Microsoft BASIC Professional
Development System (PDS) Version 7.00, correctly gives the error
"Statement cannot occur within include file." Procedure definitions
are not allowed in $INCLUDE files.

This information applies to QuickBASIC Versions 4.00b and 4.50, to
Microsoft BASIC Compiler Versions 6.00 and 6.00b, and Microsoft BASIC
PDS Version 7.00 for MS-DOS and MS OS/2.

The BC.EXE from QuickBASIC Version 4.00 correctly flags the error.

The following is a example:

   DIM arr(50)
   REM $INCLUDE: 'getsub.inc'
   FOR i = 1 TO 50
      arr(i) = i
   NEXT i
   CALL prntarray(arr())
   END

   'This is GETSUB.INC, the separate include file:
   SUB prntarray (a())
      FOR j = 1 TO 50
         PRINT a(j)
      NEXT j
   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.