Microsoft KB Archive/51863

= Failure to Flag ELSEIF THEN  as Syntax Error =

Article ID: 51863

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBASIC 4.0b, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBasic 4.5 for MS-DOS, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b

-



This article was previously published under Q51863



SYMPTOMS
In the products listed below, both the compiler and editor fail to trap an illegal block ELSEIF THEN syntax where a statement improperly follows on the same line as the THEN keyword. Despite the failure to trap this programming error, the code in the illegal syntax executes successfully.



STATUS
Microsoft has confirmed this to be a bug in the QB.EXE and BC.EXE environments of Microsoft QuickBasic versions 4.00, 4.00b, and 4.50 for MS-DOS; in the QB.EXE and BC.EXE environments of Microsoft Basic Compiler versions 6.00 and 6.00b (buglist6.00, buglist6.00b) for MS-DOS and MS OS/2; and in the QBX.EXE and BC.EXE environments of Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2 (buglist7.00, buglist7.10). Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



Code Example
The following code violates the block IF...ELSEIF...END IF statement syntax, but fails to generate a syntax error. The program successfully prints both &quot;Hello&quot; and &quot;Hello2&quot;, despite the untrapped syntax error: IF 0 THEN ELSEIF 1 THEN PRINT &quot;Hello&quot; PRINT &quot;Hello2&quot; END IF (In comparison, this code correctly generates a &quot;Syntax Error&quot; on the ELSEIF phrase in Microsoft QuickBasic for Apple Macintosh systems.)

As an offshoot issue, when you single-step through the above program in the QB.EXE or QBX.EXE editor environment with F8, the debugger fails to highlight the PRINT &quot;Hello&quot; statement but correctly highlights the PRINT &quot;Hello2&quot; statement. (&quot;Hello&quot; correctly prints despite the PRINT &quot;Hello&quot; not being highlighted.) When you correct the program by placing PRINT &quot;Hello&quot; on the next line, F8 in the debugger correctly highlights that line.

The ELSEIF...THEN line is not supposed to allow any statement following the THEN on that line. The following is the correct, required syntax: IF 0 THEN ELSEIF 1 THEN PRINT &quot;Hello&quot; PRINT &quot;Hello2&quot; END IF

Additional query words: QuickBas BasicCom buglist4.00 buglist4.00b buglist4.50

Keywords: KB51863

-

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

© Microsoft Corporation. All rights reserved.