Q43528: VARPTR$ Malfunctions on Local Variable Length STRING Arrays
Article: Q43528
Product(s): See article
Version(s): 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | buglist4.00 buglist4.00b buglist4.50 B_BasicCom | mspl13_basic
Last Modified: 21-APR-1989
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 "Illegal Function CALL" 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.
Microsoft has confirmed this problem 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 as it becomes available.
Workarounds to this problem follow in the "More Information" section.
If the following program is compiled and then executed, it will
generate an "Illegal Function CALL" when VARPTR$ is CALLed:
DECLARE SUB Drawit()
SCREEN 9
Drawit
END
SUB Drawit
DIM A$(10)
A$(1) = "U100L100D100R100" 'commands to draw a box
DRAW "X" + VARPTR$(A$(1))
END SUB
There are several easy workarounds for this problem:
1. Do not use the VARPTR$ function. The following two statements will
execute identically, and the second is much easier to implement:
DRAW "X" + VARPTR$(A$(1))
DRAW A$(1)
2. Move the DIM statement to the Module level (main) code and change
it to DIM SHARED A$(10).
3. Assign a temporary variable to A$(1) and use the temporary variable
in the VARPTR$ function.
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.