Q42588: "Variable Required" Versus "Duplicate Definition" Error
Article: Q42588 Product(s): See article Version(s): 4.00 4.00b 4.50 Operating System(s): MS-DOS Keyword(s): ENDUSER | SR# S890227-97 B_BasicCom | mspl13_basic Last Modified: 16-DEC-1989 This information applies to QuickBASIC Versions 4.00, 4.00b, and 4.50 for MS-DOS, to Microsoft BASIC Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to Microsoft BASIC PDS Version 7.00 for MS-DOS and MS OS/2. When a program attempts to define a variable and a function to have the same name, an error occurs. Normally, this error is "DUPLICATE DEFINITION." However, if the variable is first used in a FOR...NEXT statement, then the error message issued from QB.EXE (or QBX.EXE under the BASIC PDS 7.00) is "Variable Required", but from BC.EXE the two error messages "Variable Required" and "NEXT WITHOUT FOR" are generated. The following Code will generate a "Variable Required" error in QB.EXE / QBX.EXE: DECLARE FUNCTION bit% () FOR bit% = 0 TO 7 NEXT FUNCTION bit% bit% = 5 END FUNCTION Under QuickBASIC 4.50, pressing the HELP button for the "Variable Required" error box misleadingly gives the following run-time error explanation instead of the compile-time explanation: "A GET or PUT statement must specify a variable when operating on a file opened in binary mode. ERR code: #40. The compile-time meaning of "Variable Required" explained in the "Microsoft QuickBASIC: Programming in BASIC" manual for Version 4.50 is more accurate.
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.