C5_FREADSTR

 FREADSTR()
 Read characters from a binary file
------------------------------------------------------------------------------
 Syntax

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

 Arguments

     <nHandle> is the file handle obtained from FOPEN(), FCREATE(), or
     predefined by DOS.

     <nBytes> is the number of bytes to read, beginning at the current
     DOS file pointer position.

 Returns

     FREADSTR() returns a character string up to 65,535 (64K) bytes.  A null
     return value ("") indicates an error or end of file.

 Description

     FREADSTR() is a low-level file function that reads characters from an
     open binary file beginning with the current DOS file pointer position.
     Characters are read up to <nBytes> or until a null character (CHR(0)) is
     encountered.  All characters are read including control characters
     except for CHR(0).  The file pointer is then moved forward <nBytes>.  If
     <nBytes> is greater than the number of bytes from the pointer position
     to the end of the file, the file pointer is positioned to the last byte
     in the file.

     Warning!  This function allows low-level access to DOS files and
     devices.  It should be used with extreme care and requires a thorough
     knowledge of the operating system.

 Examples

     .  This example displays the ASCII values of the first 16 bytes
        of a text file:

        #include "Fileio.ch"
        //
        nHandle := FOPEN("New.txt", FC_NORMAL)
        IF FERROR() != 0
           ? "File open error:", FERROR()
        ELSE
           cString := FREADSTR(nHandle, 16)
           ? cString
           FCLOSE(nHandle)
        ENDIF

 Files   Library is CLIPPER.LIB.

See Also: BIN2I() BIN2L() BIN2W() FERROR() FOPEN() FREAD()

 

C5_FREAD

 FREAD()
 Read characters from a binary file into a buffer variable
------------------------------------------------------------------------------
 Syntax

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

 Arguments

     <nHandle> is the file handle obtained from FOPEN(), FCREATE(), or
     predefined by DOS.

     <cBufferVar> is the name of an existing and initialized character
     variable used to store data read from the specified file.  The length of
     this variable must be greater than or equal to <nBytes>.  <cBufferVar>
     must be passed by reference and, therefore, must be prefaced by the pass-
     by-reference operator (@).

     <nBytes> is the number of bytes to read into the buffer.

 Returns

     FREAD() returns the number of bytes successfully read as an integer
     numeric value.  A return value less than <nBytes> or zero indicates end
     of file or some other read error.

 Description

     FREAD() is a low-level file function that reads characters from a binary
     file into an existing character variable.  It reads from the file
     starting at the current DOS file pointer position, advancing the file
     pointer by the number of bytes read.  All characters are read including
     control, null, and high-order (above CHR(127)) characters.

     FREAD() is similar in some respects to both FREADSTR() and FSEEK().
     FREADSTR() reads a specified number of bytes from a file up to the next
     null (CHR(0)) character.  FSEEK() moves the file pointer without
     reading.

     If there is an error during the file read, FERROR() returns the DOS
     error number.  See FERROR() for the list of error numbers.

     Warning!  This function allows low-level access to DOS files and
     devices.  It should be used with extreme care and requires a thorough
     knowledge of the operating system.

 Examples

     .  This example uses FREAD() after successfully opening a file to
        read 128 bytes into a buffer area:

        #define F_BLOCK      128
        //
        cBuffer := SPACE(F_BLOCK)
        nHandle := FOPEN("Temp.txt")
        //
        IF FERROR() != 0
           ? "File open error:", FERROR()
        ELSE
           IF FREAD(nHandle, @cBuffer, F_BLOCK) <> F_BLOCK
              ? "Error reading Temp.txt"
           ENDIF
           FCLOSE(nHandle)
        ENDIF

 Files   Library is CLIPPER.LIB.

See Also: BIN2I() BIN2L() BIN2W() FCLOSE() FCREATE()



C5_FOUND

 FOUND()
 Determine if the previous search operation succeeded
------------------------------------------------------------------------------
 Syntax

     FOUND() --> lSuccess

 Returns

     FOUND() returns true (.T.) if the last search command was successful;
     otherwise, it returns false (.F.).

 Description

     FOUND() is a database function that determines whether a search
     operation (i.e., FIND, LOCATE, CONTINUE, SEEK, or SET RELATION)
     succeeded.  When any of these commands are executed, FOUND() is set to
     true (.T.) if there is a match; otherwise, it is set to false (.F.).

     If the search command is LOCATE or CONTINUE, a match is the next record
     meeting the scope and condition.  If the search command is FIND, SEEK or
     SET RELATION, a match is the first key in the controlling index that
     equals the search argument.  If the key value equals the search
     argument, FOUND() is true (.T.); otherwise, it is false (.F.).

     The value of FOUND() is retained until another record movement command
     is executed.  Unless the command is another search command, FOUND() is
     automatically set to false (.F.).

     Each work area has a FOUND() value.  This means that if one work area
     has a RELATION set to a child work area, querying FOUND() in the child
     returns true (.T.) if there is a match.

     By default, FOUND() operates on the currently selected work area.  It
     can be made to operate on an unselected work area by specifying it
     within an aliased expression (see example below).

     FOUND() will return false (.F.) if there is no database open in the
     current work area.

 Examples

     .  This example illustrates the behavior of FOUND() after a
        record movement command:

        USE Sales INDEX Sales
        ? INDEXKEY(0)              // Result: SALESMAN
        SEEK "1000"
        ? FOUND()                  // Result: .F.
        SEEK "100"
        ? FOUND()                  // Result: .T.
        SKIP
        ? FOUND()                  // Result: .F.

     .  This example tests a FOUND() value in an unselected work area
        using an aliased expression:

        USE Sales INDEX Sales NEW
        USE Customer INDEX Customer NEW
        SET RELATION TO CustNum INTO Sales
        //
        SEEK "Smith"
        ? FOUND(), Sales->(FOUND())

     .  This code fragment processes all Customer records with the key
        value "Smith" using FOUND() to determine when the key value changes:

        USE Customer INDEX Customer NEW
        SEEK "Smith"
        DO WHILE FOUND()
           .

           . <statements>
           .
           SKIP
           LOCATE REST WHILE Name == "Smith"
        ENDDO

 Files   Library is CLIPPER.LIB.

See Also: CONTINUE EOF() LOCATE SEEK SET RELATION



C5_FOPEN

 FOPEN()
 Open a binary file
------------------------------------------------------------------------------
 Syntax

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

 Arguments

     <cFile> is the name of the file to open, including the path if there
     is one.

     <nMode> is the requested DOS open mode indicating how the opened
     file is to be accessed.  The open mode is composed of elements from the
     two types of modes described in the tables below.  If just the Access
     Mode is used, the file is opened non-sharable.  The default open mode is
     zero, which indicates non-sharable and read-only.

     FOPEN() Access Modes
     ------------------------------------------------------------------------
     Mode    Fileio.ch      Operation
     ------------------------------------------------------------------------
     0       FO_READ        Open for reading (default)
     1       FO_WRITE       Open for writing
     2       FO_READWRITE   Open for reading or writing
     ------------------------------------------------------------------------

     The Sharing Modes determine how other processes may access the file.

     FOPEN() Sharing Modes 
     ------------------------------------------------------------------------
     Mode    Fileio.ch      Operation
     ------------------------------------------------------------------------
     0       FO_COMPAT      Compatibility mode (default)
     16      FO_EXCLUSIVE   Exclusive use
     32      FO_DENYWRITE   Prevent others from writing
     48      FO_DENYREAD    Prevent others from reading
     64      FO_DENYNONE    Allow others to read or write
     64      FO_SHARED      Same as FO_DENYNONE
     ------------------------------------------------------------------------

     The Access Modes in combination (+) with the Sharing modes determine the
     accessibility of the file in a network environment.

 Returns

     FOPEN() returns the file handle of the opened file in the range of zero
     to 65,535.  If an error occurs, FOPEN() returns -1.

 Description

     FOPEN() is a low-level file function that opens an existing binary file
     for reading and writing, depending on the <nMode> argument.  Whenever
     there is an open error, use FERROR() to return the DOS error number.
     For example, if the file does not exist, FOPEN() returns -1 and FERROR()
     returns 2 to indicate that the file was not found.  See FERROR() for a
     complete list of error numbers.

     If the specified file is opened successfully, the value returned is the
     DOS handle for the file.  This value is similar to an alias in the
     database system and is required to identify the open file to other file
     functions.  It is, therefore, important to assign the return value to a
     variable for later use as in the example below.

     Warning!  This function allows low-level access to DOS files and
     devices.  It should be used with extreme care and requires a thorough
     knowledge of the operating system.

 Notes

     .  Accessing files in other directories: FOPEN() does not obey
        either SET DEFAULT or SET PATH.  Instead, it searches the current DOS
        directory and path setting unless a path is explicitly stated as part
        of the <cFile> argument.

 Examples

     .  This example uses FOPEN() to open a file with  sharable
        read/write status and displays an error message if the open fails:

        #include "Fileio.ch"
        //
        nHandle := FOPEN("Temp.txt", FO_READWRITE + FO_SHARED)
        IF FERROR() != 0
           ? "Cannot open file, DOS error ", FERROR()
           BREAK
        ENDIF

 Files   Library is CLIPPER.LIB, header file is Fileio.ch.

See Also: FCLOSE() FCREATE() FERROR()

 

C5_FLOCK

 FLOCK()
 Lock an open and shared database file
------------------------------------------------------------------------------
 Syntax

     FLOCK() --> lSuccess

 Returns

     FLOCK() returns true (.T.) if an attempt to lock a database file in USE
     in the current work area succeeds; otherwise, it returns false (.F.).
     For more information on file locking, refer to the "Network Programming"
     chapter in the Programming and Utilities Guide.

 Description

     FLOCK() is a database function used in network environments to lock an
     open and shared database file, preventing other users from updating the
     file until the lock is released.  Records in the locked file are
     accessible for read-only operations.

     FLOCK() is related to USE...EXCLUSIVE and RLOCK().  USE...EXCLUSIVE
     opens a database file so that no other user can open the same file at
     the same time and is the most restrictive locking mechanism in
     Clipper.  RLOCK() is the least restrictive and attempts to place an
     update lock on a shared record, precluding other users from updating the
     current record.  FLOCK() falls in the middle.

     FLOCK() is used for operations that access the entire database file.
     Typically, these are commands that update the file with a scope or a
     condition such as DELETE or REPLACE ALL.  The following is a list of
     such commands:

     Commands that require an FLOCK()
     ------------------------------------------------------------------------
     Command                       Mode
     ------------------------------------------------------------------------
     APPEND FROM                   FLOCK() or USE...EXCLUSIVE
     DELETE (multiple records)     FLOCK() or USE...EXCLUSIVE
     RECALL (multiple records)     FLOCK() or USE...EXCLUSIVE
     REPLACE (multiple records)    FLOCK() or USE...EXCLUSIVE
     UPDATE ON                     FLOCK() or USE...EXCLUSIVE
     ------------------------------------------------------------------------

     For each invocation of FLOCK(), there is one attempt to lock the
     database file, and the result is returned as a logical value.  A file
     lock fails if another user currently has a file or record lock for the
     same database file or EXCLUSIVE USE of the database file.  If FLOCK() is
     successful, the file lock remains in place until you UNLOCK, CLOSE the
     DATABASE, or RLOCK().

     By default, FLOCK() operates on the currently selected work area as
     shown in the example below.

 Notes

     .  SET RELATION: Clipper does not automatically lock all work
        areas in the relation chain when you lock the current work area, and
        an UNLOCK has no effect on related work areas.

 Examples

     .  This example uses FLOCK() for a batch update of prices in
        Inventory.dbf:

        USE Inventory NEW
        IF FLOCK()
           REPLACE ALL Inventory->Price WITH ;
                 Inventory->Price * 1.1
        ELSE
           ? "File not available"
        ENDIF

     .  This example uses an aliased expression to attempt a file lock
        in an unselected work area:

        USE Sales NEW
        USE Customer NEW
        //
        IF !Sales->(FLOCK())
           ? "Sales is in use by another"
        ENDIF

 Files   Library is CLIPPER.LIB.

See Also: RLOCK() SET EXCLUSIVE* UNLOCK USE

 

C5_FKMAX

 FKMAX()*
 Return number of function keys as a constant
------------------------------------------------------------------------------
 Syntax

     FKMAX() --> nFunctionKeys

 Description

     FKMAX() is a compatibility function used to replicate the FKMAX()
     function in dBASE III PLUS.  As a general principle, the use of this
     function is not recommended and not needed in Clipper.  It simply
     returns a constant value of 40.

 Files   Library is EXTEND.LIB, source file is SOURCE\SAMPLE\FKMAX.PRG.

See Also: #define SET FUNCTION



C5_FKLABEL

 FKLABEL()*
 Return function key name
------------------------------------------------------------------------------
 Syntax

     FKLABEL(<nFunctionKey>) --> cKeyLabel

 Returns

     FKLABEL() returns a character string representing the name of the
     function key specified by the numeric argument, <nFunctionKey>.  If this
     argument is less than one or greater than 40, the function returns a
     null ("") string.

 Description

     FKLABEL() is a compatibility function used to replicate the FKLABEL()
     function in dBASE III PLUS.  As a general principle, the use of this
     function is not recommended and not needed in Clipper.  The function
     keys are labeled Fn, where n ranges from one to 40 and corresponds
     directly to the FKLABEL() argument.

 Files   Library is EXTEND.LIB, source file is SOURCE\SAMPLE\FKLABEL.PRG.

See Also: SET FUNCTION



C5_FILE

 FILE()
 Determine if files exist in the Clipper default directory or path
------------------------------------------------------------------------------
 Syntax

     FILE(<cFilespec>) --> lExists

 Arguments

     <cFilespec> is in the current Clipper default directory and path.
     It is a standard file specification that can include the wildcard
     characters * and ? as well as a drive and path reference.  Explicit
     references to a file must also include an extension.

 Returns

     FILE() returns true (.T.) if there is a match for any file matching the
     <cFilespec> pattern; otherwise, it returns false (.F.).

 Description

     FILE() is an environment function that determines whether any file
     matching a file specification pattern is found.  FILE() searches the
     specified directory if a path is explicitly specified.

     If a path is not specified,  FILE() searches the current Clipper
     default directory and then the Clipper path.  In no case is the DOS
     path searched.  Note also that FILE() does not recognize hidden or
     system files in its search.

 Examples

     .  In this example FILE() attempts to find Sales.dbf in other
        than the current Clipper default:

        ? FILE("Sales.dbf")               // Result: .F.
        ? FILE("\APPS\DBF\Sales.dbf")     // Result: .T.
        //
        SET PATH TO \APPS\DBF
        ? FILE("Sales.dbf")               // Result: .T.
        //
        SET PATH TO
        SET DEFAULT TO \APPS\DBF\
        ? FILE("Sales.dbf")               // Result: .T.
        ? FILE("*.dbf")                   // Result: .T.

 Files   Library is CLIPPER.LIB.

See Also: SET DEFAULT SET PATH

 

C5_FIELDWBLOCK

 FIELDWBLOCK()
 Return a set-get code block for a field in a given work area
------------------------------------------------------------------------------
 Syntax

     FIELDWBLOCK(<cFieldName>, <nWorkArea>)
        --> bFieldWBlock

 Arguments

     <cFieldName> is the name of the field specified as a character
     string.

     <nWorkArea> is the work area number where the field resides
     specified as a numeric value.

 Returns

     FIELDWBLOCK() returns a code block that, when evaluated, sets (assigns)
     or gets (retrieves) the value of <cFieldName> in the work area
     designated by <nWorkArea>.  If <cFieldName> does not exist in the
     specified work area, FIELDWBLOCK() returns an empty block.

 Description

     FIELDWBLOCK() is a database function that builds a code block.  When
     evaluated with the EVAL() function, the code block first selects the
     designated <nWorkArea>.  If an argument was passed, the code block then
     assigns the value of the argument to <cFieldName>.  If no argument was
     passed, the code block retrieves the value of <cFieldName>.  The
     original work area is then reselected before the code block returns
     control.

     Note that the specified field variable may not exist when the code block
     is created but must exist before the code block is executed.

 Notes

     .  FIELDWBLOCK() is similar to FIELDBLOCK(), except that
        FIELDBLOCK() incorporates a fixed work area into the set-get block.

 Examples

     .  This example compares FIELDWBLOCK() to a code block created
        using the macro operator.  Note that using FIELDWBLOCK() avoids the
        speed and size overhead of the macro operator:

        // Set-Get block for work area 1 defined with
        // macro operator
        bSetGet := &( "{ |setVal| IF( setVal == NIL, ;
           1->FName, 1->FName := setVal ) }" )
        // Set-Get block defined using FIELDWBLOCK()

        // bSetGet created here is the functional
        // equivalent of bSetGet above
        bSetGet := FIELDWBLOCK("FName", 1)

 Files   Library is CLIPPER.LIB.

See Also: FIELDBLOCK() MEMVARBLOCK()



C5_FIELDPUT

 FIELDPUT()
 Set the value of a field variable using the ordinal position of the field in
 the database structure
------------------------------------------------------------------------------
 Syntax

     FIELDPUT(<nField>, <expAssign>) --> ValueAssigned

 Arguments

     <nField> is the ordinal position of the field in the current
     database file.

     <expAssign> is the value to assign to the given field.  The data
     type of this expression must match the data type of the designated field
     variable.

 Returns

     FIELDPUT() returns the value assigned to the designated field.  If
     <nField> does not correspond to the position of any field in the current
     database file, FIELDPUT() returns NIL.

 Description

     FIELDPUT() is a database function that assigns <expAssign> to the field
     at ordinal position <nField> in the current work area.  This function
     allows you to set the value of a field using its position within the
     database file structure rather than its field name.  Within generic
     database service functions this allows, among other things, the setting
     of field values without use of the macro operator.

 Examples

     .  This example compares FIELDPUT() to functionally equivalent
        code that uses the macro operator to set the value of a field:

        // Using macro operator
        FName := FIELD(nField)           // Get field name
        FIELD->&FName := FVal            // Set field value
        // Using FIELDPUT()
        FIELDPUT(nField, FVal)           // Set field value

 Files   Library is CLIPPER.LIB.

See Also: FIELDGET()