Microsoft KB Archive/69108

= Instant Watch Truncates Display of String After Null Byte =

Article ID: 69108

Article Last Modified on 11/21/2006



This article was previously published under Q69108



SYMPTOMS
If you set an instant watch on a string variable that contains a null byte, CHR$(0), then instant watch will only display the contents of the string up to the null character. The problem occurs for both variable length and fixed-length string variables.



STATUS
Microsoft has confirmed this to be a bug in QB.EXE in Microsoft QuickBasic version 4.50 for MS-DOS and in QBX.EXE in Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 (buglist7.00 and buglist7.10) for MS-DOS. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
To do an instant watch on a variable in either the QB.EXE or QBX.EXE environment, you must suspend execution of the program, move the cursor under the variable you want to watch, and press SHIFT+F9. The variable name and contents will appear. Instant watch is valuable for viewing the contents of your variables during execution of the program.

Doing an instant watch on a variable (SHIFT+F9) will cause a window to pop up with the name of the variable and its value. Setting a watch on a variable is different than doing an instant watch. Setting a watch will cause a line to appear at the top of your editing screen with the name of the variable and its value. This line will remain at the top of your editing screen until you delete it.

Code Example
As the example below demonstrates, if you do an instant watch on a string variable that contains the null character, CHR$(0), then instant watch will only display the contents of the string up to the null character. If you set a watch on the same variable, the whole value of the string will be displayed. C$ = &quot;Hello&quot; + CHR$(0) + &quot;World&quot; PRINT &quot;PRESS ANY KEY TO CONTINUE&quot; DO  LOOP UNTIL INKEY$ <> &quot;&quot; The following steps demonstrate the problem:

 Run the above code in either the QB.EXE or QBX.EXE environment. While the program waits for you to press a key, press CTRL+BREAK to suspend execution of the program. Move the cursor under C$ and press SHIFT+F9. Just &quot;Hello&quot; will display. &quot;World&quot; will fail to display. Select the Add Watch button from the instant watch window. The following correct value will now display:

&quot;Hello World&quot;



Note: CHR$(0) is displayed as a blank in the watch line at the top of the editing screen.

Additional query words: QuickBas BasicCom buglist4.50

Keywords: KB69108

-

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

© Microsoft Corporation. All rights reserved.