Problem with MID$ Statement and MID$ Function in QBX.EXE (60131)






This article was previously published under Q60131

SYMPTOMS

Using the MID$ function as an argument of the MID$ statement can produce incorrect results in the QBX.EXE environment and in .EXE programs compiled with the far strings option (BC /Fs) in Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1, as shown in the program below.

The problem does not occur when compiled with near strings (the default) in the BC.EXE environment of Basic PDS 7.0 and 7.1; with the BC.EXE or QB.EXE environment of Microsoft QuickBasic version 4.0, 4.0b, or 4.5 (which have no far strings option); or with the BC.EXE or QB.EXE environment of Microsoft Basic Compiler versions 6.0 and 6.0b (which have no far strings option).

STATUS

Microsoft has confirmed this to be a bug when using far variable-length strings in Microsoft Basic PDS versions 7.0 and 7.1. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Note that the far strings option (BC /Fs) only affects variable-length string variables, and does not affect fixed-length string variables.

The program below should correctly output "1212345678". However, when run from within the QBX.EXE environment (which always uses far strings), it incorrectly outputs "1212121212". This behavior also occurs if a length% argument of 10 is used in the MID$ function. If 8 or 9 is used as the length% argument of the MID$ function, the correct output is produced. If the start% argument of the MID$ function is not taken to be 1, correct output displays.

Code Example

   A$= "1234567890"
   MID$(A$, 3) = MID$(A$, 1)
   PRINT A$
				
NOTE: The first MID$ occurrence above is the MID$ statement, and the second occurrence is the MID$ function.

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: KB60131