Microsoft KB Archive/66691

= No &quot;Block IF Without END IF&quot; Using IF...THEN REM in QB/QBX.EXE =

Article ID: 66691

Article Last Modified on 11/21/2006



This article was previously published under Q66691



SYMPTOMS
In compiled Basics that support block IF statements, the following statement correctly implies a block IF ... END IF statement, instead of a single-line IF statement syntax (whereas GW-Basic correctly treats this as a single-line IF because GW-Basic has no block IF syntax): IF expression THEN ' Comment However, using a THEN REM statement, as follows, poses a problem: IF expression THEN REM Comment The problem is that the QBX.EXE (or QB.EXE) environment interprets THEN REM as indicating a single-line IF statement, whereas BC.EXE compiler interprets THEN REM as indicating a block IF.



STATUS
Microsoft has confirmed this to be a bug in Microsoft QuickBasic versions 4.00, 4.00b, 4.50 (buglist4.00, buglist4.00b, buglist4.50) for MS-DOS; Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS and MS OS/2; and Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
When compiling the code example below, BC.EXE gives a &quot;Block IF without END IF&quot; error but the QBX.EXE or QB.EXE environment doesn't give an error, and interprets the IF ... THEN REM statement as a single-line IF statement. If an END IF statement is put at the end of the code, the code example will compile with no error in BC.EXE but the QBX.EXE or QB.EXE environment will give an &quot;END IF without block IF&quot; error.

The problem is caused by the REM statement on the IF line. In the QBX.EXE or QB.EXE environment, this case is interpreted as a single-line (non-block) IF. The BC.EXE compiler, however, strips off the REMark and interprets the line as the start of a block IF statement.

Microsoft is researching which consistent syntax requirement should be adopted for IF ... THEN REM and will post new information here in the Microsoft Knowledge Base as it becomes available.

Code Example
IF a = 3 THEN REM Gives &quot;Block IF without END IF&quot; in BC.EXE a = 5 To a avoid this problem, a remark should never be placed after a THEN statement. For example, the following code example avoids this problem by putting the remark on a separate line: REM  This remark doesn't cause a problem. IF a = 3 THEN a = 5 END IF

Additional query words: QuickBas BasicCom buglist6.00 buglist6.00b buglist7.00 buglist7.10

Keywords: KB66691

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.