Int 21H [1.0] Function 10H (16) Close file

Closes a file, flushes all MS-DOS internal disk buffers associated with the file to disk, and updates the disk directory if the file has been modified or extended.

Call with:

AH = 10H

DS:DX = segment:offset of file control block

Returns:

If function successful (directory update successful)

AL = 00H

If function unsuccessful (file not found in directory)

AL = FFH

Notes:

[1] [2] MS-DOS versions 1 and 2 do not reliably detect a floppy-disk change, and an error can occur if the user changes disks while a file is still open on that drive. In the worst case, the directory and file allocation table of the newly inserted disk can be damaged or destroyed.

[2.0+] Int 21H Function 3EH should be used in preference to this function.

Example:

Close the file that was previously opened using the file control block named myfcb.

myfcb db 0 ; drive = default

db 'QUACK ' ; filename, 8 characters

db 'DAT' ; extension, 3 characters

db 25 dup (0) ; remainder of FCB

.

.

.

mov ah,10h ; function number

mov dx,seg myfcb ; address of FCB

mov ds,dx

mov dx,offset myfcb

int 21h ; transfer to MS-DOS

or al,al ; check status

jnz error ; jump if close failed

.

.

.