Index

Function Name: CLOSE

Purpose: Close logical file
Call address: $FFC3 (hex) 65475 (decimal)
Preparation:

	Registers:	.A = LA (logical #)
	Memory:		system map
	Flags:		.C (see text description)
	Calls:		none
Results:
	Registers:	.A = error code (if any)
			.X used
			.Y used
	Memory:		logical tables updated
			STATUS, RSSTAT updated
	Flags:		.C = 1 -> error

Description: CLOSE removes the logical file (LA) passed in .A from the logical file tables and performs device-specific closing tasks. Keyboard, screen and any unOPENed files pass through. Cassette files opened for output are closed by writing the last buffer and (optionally) an EOT mark. RS-232 I/O devices are reset, losing any buffered data. Serial files are closed by transmitting a CLOSE command (if an SA was given when it was opened), sending any buffered character, and UNLSNing the bus.
There is a special provision incorporated into the CLOSE routine of systems featuring a BASIC DOS command. If the following conditions are all true, a full CLOSE is not performed; the table entry is removed but a CLOSE command is not transmitted to the device. This allows the disk command channel to be properly OPENed and CLOSEd without the disk operating system closing all files on its end:
.C = 1->indicates special CLOSE
FA >= 8->device is a disk
SA = 15->command channel
The path to CLOSE is through an indirect RAM vector at $31C. Applications may therefor provide their own CLOSE procedure or supplement the system's by redirecting this vector to their own routine.

EXAMPLE:

	LDA	#1	;la
	JSR	$FFC3	;CLOSE
	BCS	error	;(tape files only)