Microsoft KB Archive/42467

From BetaArchive Wiki
Knowledge Base

If FRE(-2) Returns Small Negative Values, Increase Stack

Article ID: 42467

Article Last Modified on 8/16/2005


  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0

This article was previously published under Q42467


FRE(-2) returns negative values if bytes are added to the stack in small increments as the stack starts to run out of space. The negative number is an indication that stack space is extremely low. To increase stack space use

   CLEAR ,,stacksize

if using QuickBasic 4.00, 4.00b, or 4.50 or Microsoft Basic Compiler Version 6.00 or 6.00b.

If using Microsoft Basic PDS Version 7.00, you can use either the CLEAR statement or the STACK statement. For example, to set the stack size as the program is running use:

   STACK stacksize

where stacksize is the number of bytes that you want for the stack. The default stack size is in QuickBasic 4.00, 4.00b, 4.50 and the Basic compiler 6.00 and 6.00b is 2000 bytes. The default stacksize in Basic PDS 7.00 is 3K under DOS or 3.5K under OS/2 protected mode. CLEAR also closes all files and releases file buffers, clears all COMMON variables, sets numeric variables and arrays to zero, sets string variables to null, and deallocates dynamic arrays. To save values in variables, use CLEAR to set the stack size in the beginning of the program. The STACK statement in Basic PDS 7.00 resets the stack size without any of the side effects of the CLEAR statement. The stack space can also be set at link time with the /ST:stacksize option, where stacksize is the number of bytes in the stack.

Additional query words: QuickBas BasicCom

Keywords: KB42467