Microsoft KB Archive/62267

= Problem Using SETMEM and SHELL in QuickBasic 4.50 =

Article ID: 62267

Article Last Modified on 11/21/2006



This article was previously published under Q62267



SYMPTOMS
Using the SETMEM function with a parameter less than 0 (zero) in Microsoft QuickBasic versions 4.00, 4.00b, and 4.50 deallocates memory from Basic's far heap. Normally, the memory can be regained with another call to SETMEM with a positive parameter. However, if a SHELL statement is executed between the two CALLs to SETMEM, the program will not be able to reclaim the memory. This happens both when executing from the QB.EXE environment or as an executable (.EXE) file that uses the BRUNxx.EXE run-time module. The only workaround is to compile the program as a stand-alone EXE using BC.EXE with the /O option.



STATUS
Microsoft has confirmed this to be a bug in QuickBasic 4.00, 4.00b, and 4.50, and in Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS (buglist6.00, buglist6.00b). This problem was corrected in Microsoft Professional Development System (PDS) version 7.00 for MS-DOS (fixlist7.00).



MORE INFORMATION
The following code sample reproduces this problem: before& = FRE(-1)               ' Get original Value. temp& = SETMEM(-30000)          ' Deallocate memory. SHELL &quot;CLS&quot; temp& = SETMEM(30000)           ' Try to Reallocate memory. after& = FRE(-1)                ' Get New value, which should be                                    ' the same value as the original. CLS PRINT &quot;Before Call: &quot;; before&  ' If the difference between these PRINT &quot;After Call: &quot;; after&    ' two values is 30000 then the ' problem is reproduced. differ& = before& - after& PRINT &quot; Difference &quot;;differ&    ' This should be 0.

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

Keywords: KB62267

-

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

© Microsoft Corporation. All rights reserved.