[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
+---------------------------------+
| FOPEN |
+---------------------------------+
FOPEN(<expC> [, <expN>])
-----------------------------------
Opens file or communication port for low-level use.
Return value - Numeric
-----------------------------------
FOPEN() will return the value -1 if for any reason it cannot open the
designated file.
Files opened with FOPEN() can be listed on the screen or to a printer
with the DISPLAY STATUS command. DISPLAY STATUS gives the following
information on low-level files:
. drive, directory and file name for each open file
. file handle number for each file
. file pointer position in each file
. read/write attributes of each file
If <expC> is a communications port, the port must first be initialized
with the DOS MODE COM command. Include either COM1 or COM2 enclosed in
quotation marks in <expC> to open a communications port. Communication
ports are always unbuffered.
The CLOSE ALL command can be used to close all FOPENed files.
Clauses
-------
<expC>
File name or communication port (e.g., COM1). If <expC> is a file
name, it may include a full path to open files in directories or on
drives that are not in the current search path. If a full file
specification is not included, FoxPro searches for the file in the
following order:
. The current directory
. The FoxPro path
. The DOS path
<expN>
File's read/write privileges or buffering scheme.
Read/Write Buffered/
<expN> Privileges Unbuffered
-----------------------------------
0 Read Only Buffered
(default)
1 Write Only Buffered
2 Read and Write Buffered
10 Read Only Unbuffered
11 Write Only Unbuffered
12 Read and Write Unbuffered
+---------------------------------+
| Program Example |
+---------------------------------+
IF FILE('errors.txt') && Does file exist?
errfile = FOPEN('errors.txt',12) && If so, open read/write
ELSE
errfile = FCREATE('errors.txt') && If not create it
ENDIF
IF errfile < 0 && Check for error opening file
WAIT 'Cannot open or create output file' WINDOW NOWAIT
ELSE && If no error, write to file
=FWRITE(errfile, 'Error information to be written here')
ENDIF
=FCLOSE(errfile) && Close file
MODIFY FILE errors.txt NOWAIT && Open file in edit window
-----------------------------------
See Also: FCHSIZE(), FCLOSE(), FCOUNT(), FCREATE(), FEOF(), FERROR(),
FFLUSH(), FGETS(), FPUTS(), FREAD(), FSEEK(), FSIZE(), FWRITE()
-----------------------------------
See Also:
FCHSIZE()
FCLOSE()
FCOUNT()
FCREATE()
FEOF()
FERROR()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson