%close() function

The %close() function closes the UNIX file specified by file.descriptor returned by a previous call to %open(), %creat(), %dup(), %socket(), or %accept().

All host OS files opened from a FlashBASIC program are closed automatically at main program termination. However, it is a safe practice to close files explicitly.

Note: You must use %socketclose if attempting to close a socket file descriptor in Windows.


var = %close(file.descriptor)
Closing one of the system files (stdin, stdout, and so on) has unpredictable results.


if %close(fd) then
   crt ’Cannot close file’

Note the use of the implicit (void) casting by not including the statement as part of an assignment. The return code of the close is thrown away.