vbdpss.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Article Q40188
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 FRE(-2) Returns Fixed Lowest Value Even After Stack Shrinks - Q40188
 
 The FRE(-2) function returns in bytes the amount of unused stack space
 available for the program.
 
 However, when the stack-space allocation decreases, the value returned
 by FRE(-2) stays fixed at the smallest size that was unused by the
 stack up to that point of program execution. In other words, the
 values successively returned by FRE(-2) never increase -- they either
 decrease or stay the same.
 
 More Information:
 
 The first sample program included below demonstrates this behavior.
 The example given is a recursive subprogram that reports the value of
 FRE(-2) on the way down and back up through 10 levels of subprogram
 recursion. As the stack space increases with the level of recursion,
 the value of FRE(-2) decreases as expected. However, as the stack
 space decreases with lower levels of recursion, the value reported by
 FRE(-2) stays "bottomed out" at the lowest value reached during
 recursion.
 
 The only way to reset the "bottomed-out" value returned by FRE(-2) is
 to end the program or execute a CLEAR statement. Note: The CLEAR
 statement erases all variables and closes all files. In some cases, as
 shown in Example 2, adding an INPUT statement before the FRE(-2)
 statement allows FRE(-2) to go back up. Adding INPUT does not help
 Example 1.
 
 Example 1 demonstrates a case in which FRE(-2) goes down and stays
 down:    See Example 1
 
 Example 2 demonstrates a case in which adding an INPUT statement
 lets the value returned by FRE(-2) go back up:
          See Example 2