Microsoft KB Archive/43528

= VARPTR$ Malfunctions on Local Variable Length STRING Arrays =

Article ID: 43528

Article Last Modified on 11/21/2006



This article was previously published under Q43528



SYMPTOMS
The VARPTR$ function returns a string representation of a variable's address that can be used by the DRAW or PLAY statements. If VARPTR$ is used on an element of a local SUBprogram variable length STRING array, it generates an &quot;Illegal Function CALL&quot; during run time. This problem does not occur when run from within the QuickBasic environment, but only when run as a compiled program. The problem occurs when the program is compiled with or without /D, or if it is compiled as a stand-alone executable file or one requiring the run-time module.



STATUS
Microsoft has confirmed this to be a bug in Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50, and the Microsoft Basic Compiler Versions 6.00 and 6.00b (buglist6.00, buglist6.00b). We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

Workarounds to this problem follow in the &quot;More Information&quot; section.



MORE INFORMATION
If the following program is compiled and then executed, it will generate an &quot;Illegal Function CALL&quot; when VARPTR$ is CALLed: DECLARE SUB Drawit SCREEN 9 Drawit END

SUB Drawit DIM A$(10) A$(1) = &quot;U100L100D100R100&quot;    'commands to draw a box DRAW &quot;X&quot; + VARPTR$(A$(1)) END SUB There are several easy workarounds for this problem:

  Do not use the VARPTR$ function. The following two statements will execute identically, and the second is much easier to implement: DRAW &quot;X&quot; + VARPTR$(A$(1)) DRAW A$(1)  Move the DIM statement to the Module level (main) code and change it to DIM SHARED A$(10). Assign a temporary variable to A$(1) and use the temporary variable in the VARPTR$ function.

Additional query words: QuickBas BasicCom buglist4.00 buglist4.00b buglist4.50

Keywords: KB43528

-

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

© Microsoft Corporation. All rights reserved.