SourcePoint AMD Help

Table of Contents

fclose

Close a file.

Syntax

fclose(file_handle)

Where:

file_handle

is a file handle returned from a previous fopen command

Discussion

The fclose function closes a file previously opened by an fopen command.

If an fopen function is executed within a procedure, then the file handle returned is valid only within that procedure. Files opened outside of a procedure have global scope and may be accessed anywhere. Any files left open when SourcePoint terminates are automatically closed.

Example

Command input:

define ord4 file1
file1 = fopen("test.dat", "w")
fputs("this is a test", file1)
fclose(file1)
define nstring buf
file1 = fopen("test.dat", "r")
fgets(buf, file1)

Result:

"this is a test"

Related Topics: