Article: Q37646
Product(s): See article
Version(s): 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | | mspl13_basic
Last Modified: 21-DEC-1989
If you use an integer for a FOR...NEXT loop counter, and the top of
the loop is 32767 (when STEP is positive) or the bottom of the loop is
-32768 (when STEP is negative), an overflow error will be correctly
generated by QB.EXE or by the EXE compiled with /d. Without the /d,
the loop does not stop at the top/bottom; it wraps around and executes
indefinitely.
The problem occurs because overflow checking is only done when /d
compiler switch is specified.
The following is a code example:
This program never finishes the FOR NEXT loop when compiled without /d.
DEFINT A-Z
FOR X = 1 TO 32767
IF X MOD 100 = 0 THEN PRINT X
NEXT X