BUG: When Compiled, PRINT CHR$(0) Incorrectly Concatenates (77877)






This article was previously published under Q77877

SYMPTOMS

Below is an example where the null character, CHR$(0), in a PRINT statement causes incorrectly concatenated output in a compiled program. The problem does not occur in interpreted programs.

Microsoft has confirmed this problem in the compiler in Microsoft QuickBasic versions 1.0, 1.0a, and 1.0b for Macintosh .

MORE INFORMATION

In the code example below, the output correctly appears on two separate lines in the interpreter in QuickBasic. However, from the compiled version of the program, the output incorrectly prints on the same line.
   A$ = CHR$(0)
   PRINT "Hi"; A$
   PRINT "Bye"; A$
   INPUT J
				
When run in the QuickBasic environment, the correct output appears as:
   Hi
   Bye
   ?
				
When compiled, however, the following incorrect output results:
   HiBye?
				
The CHR$(0) is ignored by the compiler, causing output to continue on the same line, as if the PRINT statement ended in a semicolon (;). If A$ is changed to any other ASCII character (such as CHR$(64), the @ character) the compiled code runs correctly, with the output appearing on two separate lines.

Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: kbbug KB77877