SourcePoint Intel Help

Table of Contents


Open a file for input or output.


file_handle = fopen(filename,type)




specifies a debug variable of type ord4 to receive the file handle.



specifies a filename.  See Filenames for details.



opens an existing file for input.



creates a new file, or overwrites an existing one for output.



creates a new file, or appends to an existing one for output.


The fopen function opens a file for input or output. It is similar to the "C" language fopen command except that it returns a file handle of type ord4, rather than a file pointer. This file handle is used in subsequent file I/O commands. If the file could not be opened, then 0 is returned.  If a relative path is specified for a filename, then the current working directory (specified with the cwd command) is prepended to the path. If the mode includes "b" after the initial letter, as in "rb" or "w+b", a binary file is indicated. There is no limit to the number of files that may be open.

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


Command input:

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


this is a test

Related Topics: