"Formal Parameter Specification Illegal" from BC, but Not QB (27856)






This article was previously published under Q27856

SUMMARY

For the following statement, the BC.EXE compiler correctly generates the compile-time error message "Formal parameter specification illegal," while the QuickBasic QB.EXE editor does not give any error message:
   DECLARE SUB prompt (prompt$)
				
The following is another example with the same symptoms, plus a "Duplicate Definition" error from BC.EXE:
   DECLARE FUNCTION age#
   DECLARE SUB prompt (age$)
				
The above error messages result from the requirement in QuickBasic versions 4.0, 4.0b, and 4.5, Microsoft Basic Compiler versions 6.0 and 6.0b, and Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 that procedure and variable names must be different. Therefore, programs cannot contain functions or subprograms whose names are the same as those of variables.

Note that the QB.EXE environment of QuickBasic versions 4.0, 4.0b, and 4.5 and the QBX.EXE environment of Basic PDS 7.0 correctly gives you a "Duplicate Definition" error on the following CALL or SUB statement:
   CALL PROMPT(PROMPT$)
				
Therefore, the lack of warning of "Duplicate Definition" for the DECLARE statement is a minor issue.

MORE INFORMATION

An error message occurs even in the case in which the variable and procedure names differ by a data-typing character (for example, %, &, !, #, $). The error message displays because the compiler makes no distinction between the variable "prompt$" and the subprogram name "prompt".

The requirement that procedure and variable names be different was introduced in QuickBasic version 4.0 and Basic Compiler version 6.0. This is not a requirement in earlier versions.

Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: KB27856