basic.%close

C Function/BASIC Program, Releases: AP/Unix

Closes a Unix file.

Syntax

variable=%close(file.descriptor)

Description

closes the Unix file specified by 'file.descriptor' returned by a previous call to %open(), %creat(), %dup(), %socket() or %accept().

All Unix files opened from a FlashBASIC or Pick/BASIC program are closed automatically at main program termination. It is a safe practice, though, to close files explicitly.

Example

if %close(fd) then
crt 'Cannot close file'
stop
end
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.

See Also

Command Name Type Description
basic.%creat C Function Creates new Unix file, or rewrites to existing file.
basic.%dup C Function Returns new file descriptor.
basic.cfunc Definition can be called from a Pick/BASIC program or subroutine in AP/DOS and AP/Unix implementations using a syntax similar to that of normal C.
basic.cfunction Definition Declare a list of C functions.
basic.%ttyname C Function Returns a pointer to a terminal name.
basic.%unlink C Function Removes a directory entry.
basic.%open C Function Opens a Unix file for reading or writing.
basic.%socket C Function Creates a socket.
basic.%accept C Function Accept a connection on a socket.
basic.%connect C Function Establishes a connection with a host through sockets.
basic.%fsize C Function Gets the size of a file.
basic.%listen C Function Listens for incoming connections and limits the backlog of incoming connections.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.