QB 4.x Editor Does Not Flag VARPTR$ Error, but BC.EXE Does (51075)






This article was previously published under Q51075

SYMPTOMS

VARPTR$ can be used only with simple variables and with arrays of variable-length strings. Attempting to use the VARPTR$ function on a $DYNAMIC array is a programming error. However, the QB.EXE versions 4.00, 4.00b, and 4.50 editors will not flag this as an error and will interpret and run programs that use VARPTR$ on $DYNAMIC arrays. The BC.EXE compiler Versions 4.00, 4.00b, and 4.50 correctly flag this as an error and give the error message "Dynamic array element illegal."

This problem has been corrected in QBX.EXE, which comes with Microsoft Basic Compiler Version 7.00 (fixlist7.00).

MORE INFORMATION

The VARPTR$ function is used with both the PLAY and the DRAW statements to return the string representation of the address of a variable. The following code example demonstrates the problem in the QuickBasic editor.

Code Example

     REM $DYNAMIC
     CLS
     TYPE aa
          a AS INTEGER
     END TYPE
     REDIM a(50) AS aa
     a(1).a = 10
     PRINT VARPTR$(a(1).a)
     END
				

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: KB51075