BUG: Cannot ERASE Passed Arrays That Are DIMmed in SUBprograms (61404)






This article was previously published under Q61404

SYMPTOMS

If a dynamic array is dimensioned in a SUBprogram and passed as a parameter to another SUB, any attempt to ERASE that array later in the first SUB generates an "Invalid function call" error. This problem occurs only in the interpreter.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Compiler version 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

When run in the interpreter, the following code generates an "Invalid function call" error on the ERASE statement. Note that in the interpreter, all arrays are dynamic and all SUBs must be STATIC.
CALL FirstSub

SUB FirstSub STATIC             'In interpreter SUBs must be STATIC
   DIM array%(100)              'Data type of array does not matter
   array%(100) = 255            'Set highest element to 255
   PRINT array%(100)            'Print highest element, yields 255
   CALL SecondSub(array%())     'This is necessary for the error
   ERASE array%                 'Invalid function call generated
                                'here
   DIM array%(100)              'Re-dim array, set all elements to 0
   PRINT array%(100)            'Print highest element, yields 0
END SUB

SUB SecondSub(array%()) STATIC  'Array must be passed as parameter
   'Empty SUB                   'No code is required
END SUB
				
The correct output is as follows:

255 0

In the interpreter, only the first PRINT statement is executed because the ERASE statement generates the "Invalid function call" error. If the CALL to SecondSub is not executed, the rest of the code executes correctly.

Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: kbbug KB61404