Microsoft KB Archive/61404

= BUG: Cannot ERASE Passed Arrays That Are DIMmed in SUBprograms =

Article ID: 61404

Article Last Modified on 11/21/2006



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 &quot;Invalid function call&quot; 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 &quot;Invalid function call&quot; 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 &quot;Invalid function call&quot; error. If the CALL to SecondSub is not executed, the rest of the code executes correctly.

Additional query words: MQuickB

Keywords: kbbug KB61404

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.