Run in Procedure That Dimensions Array Hangs VB Environment
ID: Q93674
|
The information in this article applies to:
-
Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0
-
Microsoft BASIC Professional Development System (PDS) for MS-DOS, versions 7.0, 7.1
-
Microsoft QuickBASIC for MS-DOS, versions 4.0, 4.0b, 4.5
SYMPTOMS
In the interpreter environment, your program may hang causing the computer
to quit responding if you have a Run statement in a procedure that also
dimensions an array. This problem does not occur in programs compiled with
the BC.EXE compiler.
STATUS
Microsoft has confirmed this to be a bug in the products listed above.
We are researching this problem and will post new information here in the
Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
This problem occurs under the following conditions:
- The Run statement is called with no parameters or with a line number
in a procedure.
- The procedure uses Dim or Redim to dimension an array local to that
procedure.
- The Sub or Function is not a static procedure.
The following example program reproduces the problem:
' Warning! This program causes the computer to hang (stop responding).
Declare Sub sub1 ()
sub1
Sub sub1
Dim y(1)
y(1) = 1
Print y(1);
' Note: Using Erase on y before Run prevents hanging.
Run
End Sub
You might use Run with no parameters or Run with a line number to restart
a program. This form of Run completely reinitializes the program's
environment -- closing files, reinitializing all static data, and
de-allocating dynamic arrays.
Several workarounds to this problem are listed below:
- Use Erase on the dynamic arrays local to the Sub procedure just prior to
using the Run statement. For example, if y() is an array local to the
Sub procedure, the following code works around the problem:
Erase y
Run
- If there is enough DGroup space, you can prevent the program from
hanging by making the Sub procedure static.
- Make the array global by declaring it as Shared or Common Shared at the
module level of the program.
- Pass the array as a parameter to the Sub procedure.
Additional query words:
VBmsdos QuickBas BasicCom 1.00 4.00 4.00b 4.50 7.00 7.10 buglist1.00 buglist4.00b buglist4.50 buglist7.00 buglist7.10
Keywords :
Version : MS-DOS:1.0,4.0,4.0b,4.5; :7.0,7.1
Platform : MS-DOS
Issue type :