Problem Passing Array in COMMON Also in SUB Argument in .QLB (32969)






This article was previously published under Q32969

SYMPTOMS

If a string array is specified in a COMMON statement and also in the argument list of a subprogram in a Quick library, garbage characters will be displayed on the screen when that array is printed from the subprogram. Under QuickBasic Versions 4.00 and 4.00b, this problem occurs only within the QB.EXE editor; the .EXE file runs without encountering any problems. Under QuickBasic Version 4.50, the problem occurs both in the QB.EXE and the .EXE unless the library is created using the debug option (/D). When the /D switch is used to build the library, the program works correctly.

Under QuickBasic Versions 4.00, 4.00b, and 4.50, if the subprogram is not part of a Quick library, the program executes correctly from inside the QuickBasic editor.

STATUS

Microsoft has confirmed this to be a bug in the QB.EXE editor in Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50, and in the Microsoft Basic Compiler Versions 6.00 and 6.00b (buglist6.00, buglist6.00b) for MS-DOS and MS OS/2. This problem has been corrected in the Microsoft Basic Compiler Version 7.00 (fixlist7.00).

MORE INFORMATION

To work around this problem, do one of the following:

  1. Use the /D (debug) option when creating the Quick library.
  2. Compile the program as an executable file to run.
  3. Do not use a Quick library. (A separately loaded source file can be substituted in the QB.EXE editor.)
The following code examples demonstrate the problem:

The main program is as follows:
     DECLARE SUB qstnaire (question$())
     DEFINT I-N
     DIM question$(5)
     COMMON question$()
     CLS
     INPUT question$(1)
     CALL qstnaire(question$())
     END
				
The subprogram in the Quick library is as follows:
     DEFINT I-N
     SUB qstnaire (question$()) STATIC
     PRINT question$(i);
     END SUB
				

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