KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q31511: Variable Passed to Dynamic SUB Changes after Integer Division

Article: Q31511
Product(s): See article
Version(s): 4.00 4.00b
Operating System(s): MS-DOS
Keyword(s): ENDUSER | buglist4.00 buglist4.00b fixlist4.50 | mspl13_basic
Last Modified: 8-DEC-1989

When run from a compiled .EXE program, the dynamic subprogram below
prints an incorrect value for a passed parameter after an unrelated
integer division. The program runs correctly in the QB.EXE editor.

Compiling the program with the BC /D (debug) option or the BC /O
option does not correct the problem.

Microsoft has confirmed this to be a problem in QuickBASIC Versions
4.00 and 4.00b, and in the Microsoft BASIC Compiler Versions 6.00 and
6.00b for MS-DOS and OS/2 (buglist6.00, buglist6.00b). This problem
was corrected in QuickBASIC Version 4.50 and in the Microsoft BASIC
Compiler Version 7.00 (fixlist7.00).

The following is a code example of the subprogram:

DECLARE SUB box (x!, y!)

REM $DYNAMIC
CLS
CALL box(50!, 2!)

REM $STATIC
SUB box (x!, y!)
  PRINT "x! = "; x!
  lf = (70 - x!) \ 2
  dn = (20 - y!) \ 2
  PRINT "x! = "; x!  ' This line prints incorrect value from .EXE program.
END SUB

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.