QBX Incorrectly Initializes Array in TYPE with OPTION BASE 1 (65083)






This article was previously published under Q65083

SYMPTOMS

QBX.EXE may not correctly initialize programs with OPTION BASE 1 and arrays in user-defined TYPEs during their initial loading. The array in the type is treated as a zero-based array instead of a one-based array. This problem is corrected by saving the file or editing either the OPTION BASE 1 line or the TYPE statement. This behavior does not occur when the program is compiled with BC.EXE.

STATUS

Microsoft has confirmed this to be a bug in the QBX.EXE environment of Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.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

Code Example

The following code example will give incorrect results (a length of 3 and a lower bound of 0) on the initial run of the program, but after saving the file (without reloading), or after editing either of the indicated lines, the program runs correctly (giving a length of 2 and a lower bound of 1):
   OPTION BASE 1                      'Editing here corrects error
   TYPE ArrayType
        Array(2) AS STRING * 1        'Editing here also corrects
   END TYPE
   DIM varArrayType AS ArrayType
   PRINT LEN(varArrayType)               'Should be 2 (incorrectly 3)
   PRINT LBOUND(varArrayType.Array)      'Should be 1 (incorrectly 0)
   END
				

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