Harbour All Functions – F

Fact

Fahrenheit

FClose()
FCount()
FCreate()
FErase()
FError()
FieldBlock()

FieldDeci()

FieldGet()

FieldName()
FieldPos()
FieldPut()

FieldSize()
FieldType()

FieldWBlock()

File()
FLock()

Floor

FOpen()

Found()

FRead()
FReadStr()
FRename()
FSeek()

FToC

FV

FWrite()

FSeek()

FSEEK()

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

FCREATE(), FERROR(), FOPEN(), FREAD(), FREADSTR(), FWRITE()

FReadStr()

FREADSTR()

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

BIN2I(), BIN2L(), BIN2W(), FERROR(), FREAD(), FSEEK()

C5 File Management

C5 File Management Commands and Functions

High Level :

ADIR()* :

Fill a series of arrays with directory information

ADIR( [ <cFilespec> ],
    [ <aFilenames> ],
    [ <aSizes> ],
    [ <aDates> ],
    [ <aTimes> ],
    [ <aAttributes> ] ) --> nFiles

CLOSE :

Close a specific set of files

CLOSE [ <idAlias> | ALL | ALTERNATE | DATABASES | FORMAT |INDEXES ]

COPY FILE :

Copy a file to a new file

COPY FILE <xcSourceFile> TO <xcTargetFile> | <xcDevice>

CURDIR() :

Return the current DOS directory

CURDIR( [ <cDrivespec> ] ) --> cDirectory

DELETE FILE :

Remove a file from disk

DELETE FILE | ERASE <xcFile>

DIR* :

Display a listing of files from a specified path

DIR [ <xcFileSpec> ]

        DIRCHANGE() :

      Change the current DOS directory

       DIRCHANGE(<cDir>) --> nSuccess

DIRECTORY() :

Create an array of directory and file information

DIRECTORY( <cDirSpec>, [ <cAttributes> ] ) --> aDirectory

 DIRMAKE()

         Create a directory

        DIRMAKE(<cNewDir>) --> nSuccess

          DIRREMOVE() :

     Remove a directory

       DIRREMOVE(<cDirName>) --> nSuccess

          DISKCHANGE() :

       Change the current DOS disk drive

        DISKCHANGE(<cDrive>) --> lSuccess

          DISKNAME() :

                  Return the current DOS drive

        DISKNAME() --> cDrive

DISKSPACE() :

Return the space available on a specified disk

DISKSPACE( [ <nDrive> ] ) --> nBytes

ERASE :

Remove a file from disk

ERASE | DELETE FILE <xcFile>

FILE() :

Determine if files exist in the default directory or path

FILE( <cFilespec> ) --> lExists

RENAME :

Change the name of a file

RENAME <xcOldFile> TO <xcNewFile>

SET ALTERNATE :

Echo console output to a text file

SET ALTERNATE TO [ <xcFile> [ADDITIVE]]
SET ALTERNATE on | OFF | <xlToggle>

SET DEFAULT :

Set the CA-Clipper default drive and directory

SET DEFAULT TO [ <xcPathspec> ]

SET PATH :

Specify the CA-Clipper search path for opening files

SET PATH TO [ <xcPathspec list> ]

TYPE :

Display the contents of a text file

TYPE <xcFile> [TO PRINTER] [TO FILE <xcOutFile> ]

Low-level :

FCLOSE() :

Close an open binary file and write DOS buffers to disk

FCLOSE( <nHandle> ) --> lError

FCREATE() :

Create and/or truncate a binary file to zero length

FCREATE( <cFile>, [ <nAttribute> ] ) --> nHandle

FERASE() :

Delete a file from disk

FERASE( <cFile> ) --> nSuccess

FERROR() :

Test for errors after a binary file operation

FERROR() --> nErrorCode

FOPEN() :

Open a binary file

FOPEN( <cFile>, [ <nMode> ] ) --> nHandle

FREAD() :

Read characters from a binary file into a buffer variable

FREAD( <nHandle>, @<cBufferVar>, <nBytes> ) --> nBytes

FREADSTR() :

Read characters from a binary file

FREADSTR( <nHandle>, <nBytes> ) --> cString

          FRENAME() :

Change the name of a file

       FRENAME( <cOldFile>, <cNewFile> ) --> nSuccess

FSEEK() :

Set a binary file pointer to a new position

FSEEK( <nHandle>, <nOffset>, [ <nOrigin> ] ) --> nPosition

FWRITE() :

Write to an open binary file

FWRITE( <nHandle>, <cBuffer>, [ <nBytes> ] )
    --> nBytesWritten

HEADER() :

Return the current database file header length

HEADER() --> nBytes