Microsoft KB Archive/89231

= FRE(-3) Gives &quot;Feature Unavailable&quot; in Compiled .EXE =

PSS ID Number: 89231

Article Last Modified on 1/8/2003

-

The information in this article applies to:


 * Microsoft Visual Basic for MS-DOS 1.0

-



This article was previously published under Q89231



SUMMARY
The function FRE(-3) returns available expanded memory in the interpreter environment (VBDOS.EXE); however, in programs compiled with BC.EXE, FRE(-3) gives the error &quot;Feature unavailable&quot; (run-time error 73). This behavior of FRE(-3) in a compiled program is not described in the &quot;Reference&quot; version 1.0 manual or in online Help.

You can determine available expanded memory by calling the Expanded Memory Manager Interrupt 67 hex, function 42 hex (Get Page Count).



MORE INFORMATION
In the Professional Edition of Microsoft Visual Basic for MS-DOS, FRE(-3) produces error 73 even in compiled programs that utilize expanded memory through overlays.

The following example program shows how to access an Expanded Memory Manager (EMM) to determine available expanded memory.

Steps to Create Example Program
 Run Visual Basic and load the Quick library VBDOS.QLB that contains the INTERRUPT procedure:

VBDOS /L

\  Enter the following code: DECLARE FUNCTION emm_free AS LONG OPTION EXPLICIT '$INCLUDE: 'vbdos.bi'

PRINT &quot;Free expanded memory:&quot;; emm_free; &quot;bytes&quot; END

'  ' Determine free expanded memory. '  FUNCTION emm_free  AS LONG

DIM emm AS INTEGER ' File handle of EMM driver. DIM ok AS INTEGER  ' True if driver is present. DIM r AS RegType   ' INTERRUPT register.

emm_free = 0

' Test for existence of EMM driver. emm = FREEFILE ON ERROR RESUME NEXT OPEN &quot;EMMXXXX0&quot; FOR INPUT AS emm ok = (ERR = 0) ON ERROR GOTO 0

' Make sure EMM driver name refers to a device, not a file. IF ok THEN r.ax = &H4400 ' IOCTL: Get Device Data. r.bx = emm CALL INTERRUPT(&H21, r, r)        ok = (r.dx AND &H40) <> 0  ' OK if bit 7 is set. CLOSE emm END IF     IF NOT ok THEN PRINT &quot;Expanded memory driver not present&quot; END IF

r.ax = &H4200 ' EMM: Get page count. CALL INTERRUPT(&H67, r, r)

IF (r.ax AND &HFF00) = 0 THEN emm_free = r.bx * 16& * 1024& ELSE PRINT &quot;Expanded memory error code &quot;; r.ax \ &H100 END IF  END FUNCTION  Press F5 to run the program. The program prints the amount of free expanded memory.

