FT_FERROR()

FT_FERROR()

Return the error code for a text file operation

Syntax

 FT_FERROR() -> nErrorNo

Arguments

None

Returns

The DOS error code if one occurred. See a reference on DOS error
codes for an explanation of what the code means.

Description

This function returns the DOS error code associated with a file
operation on the currently selected text file.

Errors could stem from any open, create, read or write operation,
among others.

Examples

IF FT_FUSE( “text.c” ) < 0 // open text file
err  :=  FT_ERROR()
QOUT( ‘Error opening file “Text.c”, error code (‘ + ;
LTRIM( STR( err ) ) + ‘)’ )
ENDIF

Source: FTTEXT.C

Author: Brice de Ganahl and Steve Larsen

See Also: FT_FUSE() FT_FSELECT() C5_FERROR

FT Text File Management

 FT_DFCLOSE()     Close file displayed by FT_DISPFILE()
 FT_DFSETUP()     Set up parameters for FT_DISPFILE()
 FT_DISPFILE()    Browse a text file
 FT_FAPPEND()     Appends a line to the currently selected text file
 FT_FDELETE()     Deletes a line from the currently selected text file
 FT_FEOF()        Determine when end of text file is encountered
 FT_FERROR()      Return the error code for a text file operation 
 FT_FGOBOT()      Go to the last record in a text file
 FT_FGOTO()       Move record pointer to specific record in a text file
 FT_FGOTOP()      Go to the first record in a text file
 FT_FINSERT()     Inserts a line in the currently selected text file
 FT_FLASTRE()     Get the no. of records in the currently selected text file
 FT_FREADLN()     Read a line from the currently selected text file
 FT_FRECNO()      Return the current record number of a text file
 FT_FSELECT()     Select a text file workarea
 FT_FSKIP()       Move the record pointer to a new position in a text file
 FT_FUSE()        Open or close a text file for use by the FT_F* functions
 FT_FWRITELN()    Write a line to the currently selected text file

 

FT_FUSE

FT_FUSE()
 Open or close a text file for use by the FT_F* functions

 Syntax

      FT_FUSE( [ <cFile> ] [, <nMode> ] ) -> nHandle | NIL

 Arguments

     <cFile> is the text file you want to open.  If not specified,
     the file currently open, if any, will be closed.

     <nMode> is the open mode for the file.  Please refer to the
     discussion of open modes under FOPEN() in the Clipper manual
     and FILEIO.CH for a list of allowable open modes.  If not
     specified, the file will be opened with a mode of
     FO_READ + FO_SHARED (64).

 Returns

     If <cFile> is passed and the file is opened successfully, an
     integer containing the file handle.  If the file cannot be
     opened, -1 will be returned.

     If FT_FUSE() is called without any arguments, it will close the
     text file in the current "text area" and return NIL.

 Description

     The FT_F*() file functions are for reading text files, that is,
     files where each line (record) is delimited by a CRLF pair.

     Each file is opened in its own "workarea", similar to the concept
     use by dbf files.  As provided, a maximum of 10 files (in 10
     workareas) can be opened (assuming there are sufficient file
     handles available).  That number may be increased by modifying
     the #define TEXT_WORKAREAS in the C source code and recompiling.

 Examples

     FT_FUSE( "text.c" )      // open text file
     DO WHILE !FT_FEOF()
        ? FT_FREADLN()
        FT_FSKIP()
     ENDDO
     FT_FUSE()                // close file

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

See Also: FT_FUSE() FT_FSELECT()

FT_FSELECT

FT_FSELECT()
 Select a text file workarea

 Syntax

      FT_FSELECT( [ <nArea> ] ) -> nArea

 Arguments

     <nArea> is the text file workarea to select.

 Returns

     The current selected text file area.

 Description

     This function selects a text file "workarea" from 1 to 10.  A
     file may or may not be open in the selected area.

     Passing 0 for <nArea> selects the next available workarea, similar
     to Clipper's SELECT 0 command.

     Each file is opened in its own "workarea", similar to the concept
     used by dbf files.  As provided, a maximum of 10 files (in 10
     workareas) can be opened (assuming there are sufficient file
     handles available).  That number may be increased by modifying
     the #define TEXT_WORKAREAS in the C source code and recompiling.

     All the FT_F*() file functions operate on the file in the currently
     selected text file workarea.

     Text file workareas are separate from and independent of Clipper's
     database workareas.

 Examples

     FT_FSELECT(1)
     nFile1 := FT_FUSE( "temp.c" )
     ? FT_FLASTRE()                 // no. of lines in temp.c
     FT_FSELECT(2)
     nFile2 := FT_FUSE( "temp.h" )
     ? FT_FLASTRE()                 // no. of lines in temp.h

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

See Also: FT_FUSE()

FT_FAPPEND

FT_FAPPEND()
 Appends a line to the currently selected text file

 Syntax

      FT_FAPPEND( [ < nLines > ] ) -> NIL

 Arguments

     <nLines> is the number of lines that should be appended to the
     end of the currently selected text file.

     If <nLines> is omitted, one record is appended.

 Returns

     NIL

 Description

     This function appends a line of text to the file in the currently
     selected text file workarea.  Text lines are delimited with a
     CRLF pair.  The record pointer is moved to the last appended
     record.

     Multiple lines may be appended with one call to FT_FAPPEND().

     A text file "record" is a line of text terminated by a CRLF pair.
     Each line appended with this function will be empty.

     NOTE:  Occasionally a text file may contain a non-CRLF terminated
     line, at the end of the file ("stragglers").  This function assumes
     these stragglers to be the last line of the file, and begins
     appending the new lines after this line.  In other words, if the
     last line in the text file is not terminated with a CRLF pair prior
     to calling FT_FAPPEND(), the function will terminate that last line
     before appending any new lines.

 Examples

     // add a blank line of text to a file
     FT_FUSE( "test.txt" )

     ?FT_FRECNO()           // displays 5

     FT_FAPPEND()

     ?FT_FRECNO()           // displays 6

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

See Also: FT_FRECNO() FT_FDELETE() FT_FINSERT() FT_FLASTRE()

FT_DISPFILE

FT_DISPFILE()
 Browse a text file

 Syntax

      FT_DISPFILE() -> cExitkey

 Arguments

     None

 Returns

     The ASCII keystroke that terminated FT_DISPFILE()

 Description

     This routine displays a text file within a defined window using as
     little memory as possible.  The text file to display has to be
     present or an error value of 0 is returned (as a character.)

     Assumptions: The routine assumes that all lines are terminated
                  with a CR/LF sequence (0x0d and 0x0a).

     Note:        Make sure you allocate a buffer large enough to hold
                  enough data for the number of lines that you have
                  in the window.  Use the following formula as a
                  guideline - buffer size = (# of line) + 1 * RMargin
                  this is the smallest you should make the buffer and
                  for normal use I recommend 4096 bytes.

     Cursor Keys: Up, Down    - moves the highlight line
                  Left, Right - moves the window over nColSkip col's
                  Home        - moves the window to the far left
                  End         - moves the window to the nRMargin column
                  PgUp, PgDn  - moves the highlight one page
                  Ctrl-PgUp   - moves the highlight to the file top
                  Ctrl-PgDn   - moves the highlight to the file bottom
                  Ctrl-Right  - moves the window 16 col's to the right
                  Ctrl-Left   - moves the window 16 col's to the left

                  Esc, Return - terminates the function

                  All other keys are ignored unless they are specified
                  within cExitKeys parameter.  This list will tell the
                  routine what keys terminate the function.  Special
                  keys must be passed by a unique value and that value
                  can be found by looking in the keys.h file.

 Examples

     @ 4,9 TO 11,71

     FT_DFSETUP("test.txt", 5, 10, 10, 70, 1, 7, 15,;
                 "AaBb" + Chr(143), .T., 5, 132, 4096)

     cKey = FT_DISPFILE()

     FT_DFCLOSE()

     @ 20,0 SAY "Key that terminated FT_DISPFILE() was: " + '[' + cKey + ']'

 Source: DISPC.C

 Author: Mike Taylor

See Also: FT_DFSETUP() FT_DFCLOSE()

FT_DFSETUP

FT_DFSETUP()
 Set up parameters for FT_DISPFILE()

 Syntax

      FT_DFSETUP( <cInFile>, <nTop>, <nLeft>, <nBottom>, <nRight>, ;
               <nStart>, <nCNormal>, <nCHighlight>, <cExitKeys>,   ;
               <lBrowse>, <nColSkip>, <nRMargin>, <nBuffSize> ) -> nResult

 Arguments

        <cInFile>     - text file to display (full path and filename)
        <nTop>        - upper row of window
        <nLeft>       - left col of window
        <nBottom>     - lower row of window
        <nRight>      - right col of window
        <nStart>      - line to place highlight at startup
        <nCNormal>    - normal text color     (numeric attribute)
        <nCHighlight> - text highlight color  (numeric attribute)
        <cExitKeys>   - terminating key list  (each byte of string is a
                        key code)
        <lBrowse>     - act-like-a-browse-routine flag
        <nColSkip>    - col increment for left/right arrows
        <nRMargin>    - right margin - anything to right is truncated
        <nBuffSize>   - size of the paging buffer

 Returns

     0 if successful, FError() code if not

 Description

     Note: make sure you allocate a buffer large enough to hold enough
     data for the number of lines that you have in the window.  Use the
     following formula as a guideline:

        buffer size = (# of line) + 1 * RMargin

     This is the smallest you should make the buffer.  For normal use,
     4096 bytes is recommended

 Examples

     @ 4,9 TO 11,71

     FT_DFSETUP("test.txt", 5, 10, 10, 70, 1, 7, 15,;
                "AaBb" + Chr(143), .T., 5, 132, 4096)

     cKey = FT_DISPFILE()

     FT_DFCLOSE()

     @ 20,0 SAY "Key that terminated FT_DISPFILE() was: " + '[' + cKey + ']'

 Source: DFILE.PRG

 Author: Mike Taylor

See Also: FT_DISPFILE() FT_DFCLOSE()

FT_DFCLOSE

FT_DFCLOSE()
 Close file displayed by FT_DISPFILE()

 Syntax

      FT_DFCLOSE() -> NIL

 Arguments

     None

 Returns

     NIL

 Description

     Closes the file opened by FT_DFSETUP()

 Examples

     @ 4,9 TO 11,71

     FT_DFSETUP("test.txt", 5, 10, 10, 70, 1, 7, 15,;
                 "AaBb" + Chr(143), .T., 5, 132, 4096)

     cKey = FT_DISPFILE()

     FT_DFCLOSE()

     @ 20,0 SAY "Key that terminated FT_DISPFILE() was: " + '[' + cKey + ']'

 Source: DFILE.PRG

 Author: Mike Taylor

See Also: FT_DFSETUP() FT_DISPFILE()