"Variable Name Not Unique" if Variable Name Same as Parameter (81453)



The information in this article applies to:

  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.1
  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5

This article was previously published under Q81453

SYMPTOMS

The BC.EXE compiler incorrectly reports "Variable name not unique" when a module contains the following, in order:
  1. In the module level, a string constant that ends with a period character. For example, any one of the following statements:
          PRINT ".";
          a$ = "abc."
          c = ASC(".")
          CHDIR ".."
  2. In the module level, a variable that was not declared with "DIM <variable> AS <type>". For example, one of the following statements:
          y = 1
          PRINT y
  3. In a SUB or FUNCTION procedure, a parameter declared with "DIM <parameter> AS <user-type>," where <parameter> has the same name as the variable in the module-level and <user-type> is a user-defined type name. For example:
          SUB s (y as userType)

STATUS

Microsoft has confirmed this to be a bug in the BC.EXE compiler of Microsoft Basic Compiler versions 6.0 and 6.0b; Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1; and QuickBasic versions 4.0, 4.0b, and 4.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Problem

The following example program has no output, but when you try to compile it, it demonstrates the problem.
TYPE t
  x AS INTEGER
END TYPE

' Un-remark the following line to work around the problem
' DIM y AS SINGLE
PRINT "."; y

SUB s (y AS t) ' BC.EXE incorrectly reports "Variable name not unique"

END SUB

>From within the environment, the output will be : ".  0". But if you
try to compile it, BC.EXE will report the problem on the SUB
statement.

To work around this problem, declare the module-level variable with
"DIM ... AS ...." For example:

    ' Insert this line of code before the PRINT statement
    DIM y AS SINGLE
				

Modification Type:MinorLast Reviewed:1/8/2003
Keywords:KB81453 kbAudDeveloper