Mismatched Fixed-length String Passed by Value Hangs QB 4.5 (76665)






This article was previously published under Q76665

SYMPTOMS

Passing a fixed-length string by value to a subprogram will hang QB.EXE if all the following conditions are met:

  • The subprogram expects two or more parameters, the first of which is a string.
  • The call to the subprogram has fewer arguments than the subprogram has parameters.
  • A fixed-length string is passed by value in the first argument position.
Normally the QB.EXE environment will report an "Argument Count Mismatch" error when you fail to pass the correct number of parameters. However, if all the above conditions are met, QB.EXE will hang when you choose the Start or Make EXE File command from the Run menu. This problem can be avoided by ensuring that you pass the correct number of parameters to the SUB.

STATUS

Microsoft has confirmed this to be a bug with the QB.EXE environment of Microsoft QuickBasic 4.5. We are researching the problem and will post new information here as it becomes available.

This problem does not occur in QuickBasic 4.0 or 4.0b or Basic PDS 7.1 (fixlist7.10). In these versions, the programming environment flags the incorrect number of arguments as expected with the "Argument Count Mismatch" error message.

MORE INFORMATION

The following code example demonstrates the problem. WARNING: Running or trying to make an .EXE file from this code will cause your computer to hang.
'-------------------------------------------
DECLARE SUB Mysub (p1$, p2$)  ' Note that all conditions are met:
             ' Two parameters and less than two arguments
DIM arg AS STRING * 10 ' A fixed-length string (length doesn't matter)

Mysub (arg)   ' One string passed by value. (Parentheses around each
              ' argument denote passing by value.)
'  or you can use the following equivalent syntax to pass by value:
' CALL Mysub ((Argument))

' NOTE: When you use an explicit CALL statement in the syntax, the
' argument list must be enclosed in parentheses as shown. The extra
' interior set of parentheses is required for passing by value.

END

SUB Mysub(p1$, p2$)   ' The types of the second and following
END SUB             ' parameters do not matter as long as the
                    ' first one is a string.
				

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