FOR with Conditional IF...THEN NEXT Causes Problems (35718)
The information in this article applies to:
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
This article was previously published under Q35718 SUMMARY
Executing an isolated NEXT statement within a block IF...END IF
statement produces an error in the Macintosh QuickBASIC interpreter;
however, it will compile and run.
Executing the NEXT statement without the matching FOR in the same IF
statement is a bad programming practice because it may cause problems
with the stack. This practice can cause the stack to overflow and
generate a memory error, or cause the program's flow of control to
branch incorrectly. (In the interpreter, the stack keeps track of
where to return when a loop is finished.)
The NEXT statement should never be executed conditionally in a
single-line or block IF...END IF statement. It is easy to find an
alternative flow-of-control structure that performs the same logic.
Modification Type: | Minor | Last Reviewed: | 1/9/2003 |
---|
Keywords: | KB35718 |
---|
|