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_FWRITELN

FT_FWRITELN()
 Write a line to the currently selected text file

 Syntax

      FT_FWRITELN( < cData >, [ < lInsert > ] ) -> NIL

 Arguments

     <cData> is a string of data to write to the file at the current
      record position.

     <lInsert> is a logical indicating whether the contents
     of the current record are to be preserved, that is, if lInsert
     evaluates to .T., the a new record is inserted at the current
     position.  The current record then is pushed down to FT_FRECNO()+1.

     If lInsert is .F. or omitted, the current record is replaced by
     cData.

 Returns

     NIL

 Description

     This function writes 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 not moved.

     The contents of the current record are updated to reflect the new
     new line written, unless the Insert option is selected.

     Writing a null string has the effect of clearing the current line
     if in overstrike mode, else inserting a new line (same as
     FT_FINSERT()).

     A text file "record" is a line of text terminated by a CRLF pair.

 Examples

     // write a line of text to a file
     FT_FUSE( "config.sys" )
     DO WHILE UPPER( FT_FREADLN() ) != "FILES=" .AND. !F_FEOF()
        FT_FSKIP()
     ENDDO

     FT_FWRITELN( "FILES=30", FT_FEOF() )

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

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

FT_FRECNO

FT_FRECNO()
 Return the current record number of a text file

 Syntax

      FT_FRECNO() -> nRecNo

 Arguments

     None

 Returns

     The current record number of a text file or 0 if no file is open.

 Description

     This function returns the current record number of the file open
     in the currently selected text file workarea.

     A text file "record" is a line of text terminated by a CRLF pair.

 Examples

     FT_FUSE( "text.c" )      // open text file
     DO WHILE !FT_FEOF()
        ? FT_FREADLN()        // read thru file
        FT_FSKIP()
     ENDDO
     FT_FGOTOP()              // go back to top
     ? FT_FRECNO()            // 1

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

See Also: FT_FSELECT() FT_FUSE() FT_FGOTOP() FT_FGOBOT()

FT_FREADLN

FT_FREADLN()
 Read a line from the currently selected text file

 Syntax

      FT_FREADLN() -> cLine

 Arguments

     None

 Returns

     A string containing the current record in a text file.

 Description

     This function returns a line of text read from the file in the
     currently selected text file workarea.  Text lines are delimited
     with a CRLF pair.  The record pointer is not moved.

     A text file "record" is a line of text terminated by a CRLF pair.

 Examples

     // display each record of a text file
     FT_FUSE( "text.c" )
     DO WHILE ! FT_FEOF()
        ? FT_FREADLN()
        FT_FSKIP()
     ENDDO

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

See Also: FT_FUSE() FT_FWRITELN() FT_FRECNO() FT_FGOTOP()

FT_FINSERT

FT_FINSERT()
 Inserts a line in the currently selected text file

 Syntax

      FT_FINSERT( [ < nLines > ] ) -> NIL

 Arguments

     <nLines> is the number of lines that should be inserted at the
     current record position.

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

 Returns

     NIL

 Description

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

     An optional parameter allows multiple insertions to take place
     with a single call to FT_FINSERT().

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

 Examples

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

     FT_FINSERT()

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

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

FT_FDELETE

FT_FDELETE()
 Deletes a line from the currently selected text file

 Syntax

      FT_FDELETE( [ < nLines > ] ) -> NIL

 Arguments

     <nLines> is the number of lines to be eliminated, beginning with
     the current record position.

     If <nLines> is omitted, the current record is deleted only.

 Returns

     NIL

 Description

     This function deletes one or several lines of text from the file
     in the currently selected text file workarea.  Text lines are
     delimited with a CRLF pair.  The record pointer is not moved.

 Examples

     // delete the next 4 lines from a file
     FT_FUSE( "test.txt" )

     FT_FDELETE( 4 )

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

See Also: FT_FAPPEND() FT_FRECNO() FT_FINSERT()

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()