Q65396: EOF in 7.00 Returns "Nonzero" for TRUE, But 4.50 Returns -1
Article: Q65396
Product(s): See article
Version(s): 7.00 7.10 | 7.00 7.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | SR# S900822-29 B_QuickBas | mspl13_basic
Last Modified: 4-SEP-1990
The EOF function has changed slightly from QuickBASIC versions 4.50
and earlier to Microsoft BASIC Professional Development System (PDS)
versions 7.00 and later. In QuickBASIC, the EOF function will return 0
(zero) for FALSE and -1 for TRUE. In BASIC PDS 7.00, EOF still returns
0 for FALSE, but it returns "nonzero" for TRUE. This means that EOF
will return a positive or negative number other than 0 if the end of
the file has been reached or if you are at the "end" of an ISAM table.
Previous QuickBASIC programs that hard coded a check for -1 will have
to be changed to check for a nonzero value. Since 0 is equivalent to
FALSE and nonzero evaluates to TRUE in BASIC, this is an easy change
to make. For instance, you do not need to check "IF EOF = -1 THEN
GOSUB foo"; instead, you can use "IF EOF THEN GOSUB foo". This second
check will work in any version of Microsoft BASIC.
This information applies to Microsoft BASIC Professional Development
System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2. This
article documents a change from Microsoft QuickBASIC 1.00, 1.01, 1.02,
2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50 for MS-DOS, and from Microsoft
BASIC Compiler versions 6.00 and 6.00b for MS-DOS and MS OS/2.
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.