FClose()
FCount()
FCreate()
FErase()
FError()
FieldBlock()
FieldName()
FieldPos()
FieldPut()
Positions the file pointer in a file opened with low-level access
Syntax
FSEEK( <nHandle>, <nOffset>, [<nOrigin>] ) --> nPosition
Arguments
<nHandle> DOS file handle.
<nOffset> The number of bytes to move.
<nOrigin> The relative position in the file.
Returns
<nPosition> the current position relative to begin-of-file
Description
This function sets the file pointer in the file whose DOS file handle is <nHandle> and moves the file pointer by <expN2> bytes from the file position designated by <nOrigin>. The returned value is the relative position of the file pointer to the beginning-of-file marker once the operation has been completed.
<nHandle> is the file handle number. It is obtained from the FOPEN() or FCREATE() function.
The value of <nOffSet> is the number of bytes to move the file pointer from the position determined by <nOrigin>. The value of <nOffset> may be a negative number, suggesting backward movement.
The value of <nOrigin> designates the starting point from which the file pointer should he moved, as shown in the following table:
<nOrigin> fileio.ch File position ----------- ------------- ---------------------------------- 0 FS_SET Beginning of file 1 FS_RELATIVE Current file pointer position 2 FS_END End of file
If a value is not provided for <nOrigin>, it defaults to 0 and moves the file pointer from the beginning of the file.
Examples
// here is a function that read one text line from an open file // nH = file handle obtained from FOpen() // cB = a string buffer passed-by-reference to hold the result // nMaxLine = maximum number of bytes to read FUNCTION FREADln( nH, cB, nMaxLine ) LOCAL cLine, nSavePos, nEol, nNumRead cLine := Space( nMaxLine ) cB := "" nSavePos := FSeek( nH, 0, FS_RELATIVE ) nNumRead := FRead( nH, @cLine, nMaxLine ) IF ( nEol := At( hb_eol(), SubStr( cLine, 1, nNumRead ) ) ) == 0 cB := cLine ELSE cB := SubStr( cLine, 1, nEol - 1 ) FSEEK( nH, nSavePos + nEol + 1, FS_SET ) ENDIF RETURN nNumRead != 0
Compliance
Clipper
Files
Library is rtl Header is fileio.ch
Seealso
Reads a string from a file opened with low-level access
Syntax
FREADSTR(<nHandle>, <nBytes>) --> cString
Arguments
<nHandle> DOS file handle number.
<nBytes> Number of bytes to read.
Returns
<cString> an character expression
Description
This function returns a character string of <nBytes> bytes from a file whose DOS file handle is <nHandle>.
The value of the file handle <nHandle> is obtained from either the FOPEN() or FCREATE() functions.
The value of <nBytes> is the number of bytes to read from the file. The returned string will be the number of characters specified in <nBytes> or the number of bytes read before an end-of-file charac- ter (ASCII 26) is found.
NOTE This function is similar to the FREAD() function, except that it will not read binary characters that may he required as part of a header of a file construct. Characters Such as CHR(0) and CHR(26) may keep this function from performing its intended operation. In this event, the FREAD() function should he used in place of the FREADSTR() function.
Examples
#include "fileio.ch" IF ( nH := FOpen( "x.txt" ) ) != F_ERROR cStr := FReadStr( nH, 100 ) ? cStr FClose( nH ) ENDIF
Compliance
Clipper
Platforms
All (64K)
Files
Library is rtl
Seealso
Fill a series of arrays with directory information
ADIR( [ <cFilespec> ], [ <aFilenames> ], [ <aSizes> ], [ <aDates> ], [ <aTimes> ], [ <aAttributes> ] ) --> nFiles
Close a specific set of files
CLOSE [ <idAlias> | ALL | ALTERNATE | DATABASES | FORMAT |INDEXES ]
Copy a file to a new file
COPY FILE <xcSourceFile> TO <xcTargetFile> | <xcDevice>
Return the current DOS directory
CURDIR( [ <cDrivespec> ] ) --> cDirectory
Remove a file from disk
DELETE FILE | ERASE <xcFile>
Display a listing of files from a specified path
DIR [ <xcFileSpec> ]
Change the current DOS directory
DIRCHANGE(<cDir>) --> nSuccess
Create an array of directory and file information
DIRECTORY( <cDirSpec>, [ <cAttributes> ] ) --> aDirectory
Create a directory
DIRMAKE(<cNewDir>) --> nSuccess
Remove a directory
DIRREMOVE(<cDirName>) --> nSuccess
Change the current DOS disk drive
DISKCHANGE(<cDrive>) --> lSuccess
Return the current DOS drive
DISKNAME() --> cDrive
Return the space available on a specified disk
DISKSPACE( [ <nDrive> ] ) --> nBytes
Remove a file from disk
ERASE | DELETE FILE <xcFile>
Determine if files exist in the default directory or path
FILE( <cFilespec> ) --> lExists
Change the name of a file
RENAME <xcOldFile> TO <xcNewFile>
Echo console output to a text file
SET ALTERNATE TO [ <xcFile> [ADDITIVE]] SET ALTERNATE on | OFF | <xlToggle>
Set the CA-Clipper default drive and directory
SET DEFAULT TO [ <xcPathspec> ]
Specify the CA-Clipper search path for opening files
SET PATH TO [ <xcPathspec list> ]
Display the contents of a text file
TYPE <xcFile> [TO PRINTER] [TO FILE <xcOutFile> ]
Close an open binary file and write DOS buffers to disk
FCLOSE( <nHandle> ) --> lError
Create and/or truncate a binary file to zero length
FCREATE( <cFile>, [ <nAttribute> ] ) --> nHandle
Delete a file from disk
FERASE( <cFile> ) --> nSuccess
Test for errors after a binary file operation
FERROR() --> nErrorCode
Open a binary file
FOPEN( <cFile>, [ <nMode> ] ) --> nHandle
Read characters from a binary file into a buffer variable
FREAD( <nHandle>, @<cBufferVar>, <nBytes> ) --> nBytes
Read characters from a binary file
FREADSTR( <nHandle>, <nBytes> ) --> cString
Change the name of a file
FRENAME( <cOldFile>, <cNewFile> ) --> nSuccess
Set a binary file pointer to a new position
FSEEK( <nHandle>, <nOffset>, [ <nOrigin> ] ) --> nPosition
Write to an open binary file
FWRITE( <nHandle>, <cBuffer>, [ <nBytes> ] ) --> nBytesWritten
Return the current database file header length
HEADER() --> nBytes