advr.hlp (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.
FRE Function Details
  Summary  Details  Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
 FRE(numeric-expression% | stringexpression$)
 
 Usage Notes
   ■ When a string expression is specified, the FRE function compacts the
     free string space into a single block, then returns the amount of
     available string space.
 
   ■ FRE(-2) returns meaningful values only when a program is executing.
     Values returned by FRE(-2) are not accurate when the function is
     called from the Immediate window, during program tracing, or when
     watching a variable. The unused stack space indicates how much stack
     is needed so that DGROUP can be reclaimed.
 
   ■ If expanded memory is not available, FRE(-3) returns the error message,
     "Feature unavailable."
 
   ■ FRE(-3) is no longer available with compiled programs using overlays.
     If you are running a compiled application using an earlier version of
     Basic expanded-memory overlays, the value returned by FRE(-3) is based
     on the total amount of expanded memory available. (When using overlays,
     you cannot limit the amount of expanded memory used by your program.)
 
   ■ If you are running a program with no forms loaded, FRE(-4) returns the
     error message, "No currently active form."
 
   ■ If you start Visual Basic (VBDOS.EXE) without the /E:n switch, you will
     be using all expanded memory available on your computer.
     See: VBDOS Command-Line Options
 
   ■ If you start Visual Basic (VBDOS.EXE) with the /E:n switch, you can
     limit the amount of expanded memory available to your program. For
     example, if your computer has 5 MB of expanded memory but you want to
     use only 4MB of expanded memory, you can start Visual Basic with this:
 
         VBDOS /E:4096
 
     If you have specified 4MB of expanded memory as shown above, and then
     you use 2MB of expanded memory in your program, FRE(-3) returns 2048.
 
   ■ You can use the FRE function to approximate the amount of memory taken
     up by a form or controls placed on your form. For example:
 
         SUB Form_Click ()
              Loaded! = FRE(-1)
              UNLOAD Form1
              Unloaded! = FRE(-1)
              SHOW
              PRINT STR$(Unloaded! - Loaded!)
         END SUB
 
     You can write an event procedure similar to the one above to determine
     the amount of memory used by a given control before or after placing
     that control on a form. For example, if:
 
         A = Size, in bytes, of default form with no controls
         B = Size, in bytes, of form with one control
 
     then:
 
         B - A = Amount of memory, in bytes, taken up by the control