Microsoft KB Archive/41398

= Garbage with PRINT TAB, Array Element in .EXE Compiled in 4.5 =

Article ID: 41398

Article Last Modified on 11/21/2006



This article was previously published under Q41398



SYMPTOMS
A QuickBasic version 4.5 program compiled with BC.EXE displays garbage (a memory dump) on the screen (plus random beeps) when all of the following conditions occur simultaneously:


 * 1) Two consecutive PRINT, PRINT#, or LPRINT statements occur, the second of which uses the TAB function.
 * 2) The variable being printed is an element of an array.
 * 3) The program is compiled with BC without the /D option.
 * 4) The program is compiled without the /O option.



STATUS
Microsoft has confirmed this to be a bug in QuickBasic version 4.5. This problem is corrected in Microsoft Basic Professional Development System (PDS) version 7.0 (fixlist7.00).

This problem does not occur in QuickBasic version 4.0 or 4.0b.



MORE INFORMATION
There are several workarounds for this problem:


 * 1) Use the /D (debug) switch when compiling.
 * 2) Replace the TAB function with an equivalent number of spaces.
 * 3) Put an IF statement between the PRINT, PRINT#, or LPRINT statements (as shown in comment in program below).
 * 4) Use local variables for the subscripts.
 * 5) Use the /X switch when compiling, which is normally used to indicate the presence of ON ERROR with RESUME, RESUME NEXT, or RESUME 0.
 * 6) Use the /AH switch when compiling. (Invoking QB /AH will ensure that the Make EXE File command compiles with /AH).

Code Example
DIM lbc%(8), wmsg$(8) COMMON SHARED lbc%, wmsg$ ' OPEN &quot;CON&quot; FOR OUTPUT AS #1   ' This lets you use PRINT#1 below. CLS FOR i% = 1 TO 8 lbc%(i%) = i% wmsg$(i%) = STRING$(17, 48 + i%) NEXT j% = 58 FOR i% = 1 TO 4 LOCATE 2 + i%, 3 PRINT wmsg$(lbc%(i%));  ' Also, PRINT#1, and LPRINT give problem ' IF i%=4 THEN j%= 58 ' INSERT THIS STATEMENT TO CORRECT PROBLEM ' A simple assignment will not correct the problem. ' The following statement fails: PRINT TAB(j%); wmsg$(lbc%(i% + 4)); ' Also PRINT#1, or LPRINT ' The following statement also fails: ' PRINT wmsg$(lbc%(i%)); TAB(j%); wmsg$(lbc%(i% + 4)); NEXT i%

Additional query words: QuickBas 4.00 4.00b 4.50 7.00 buglist4.50 SR# S881221-120

Keywords: KB41398

-

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

© Microsoft Corporation. All rights reserved.