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_FSKIP

FT_FSKIP()
 Move the record pointer to a new position in a text file

 Syntax

      FT_FSKIP( [ <nLines> ] ) -> NIL

 Arguments

     <nLines> is the number of lines to skip.  Defaults to 1 if
     not specified.

 Returns

     NIL

 Description

     This function moves the text file record pointer, similar to
     the CLIPPER SKIP command.

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

FT_FLASTRE

FT_FLASTRE()
 Get the no. of records in the currently selected text file

 Syntax

      FT_FLASTRE() -> nLastRecordNum

 Arguments

     None

 Returns

     An integer containing the number of records in the text file in
     the currently selected text file workarea, or zero if no file
     is currently open in the workarea.

 Description

     This function returns the number of the last record in a text file.

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

 Examples

     FT_FUSE( "text.c" )
     ? FT_FLASTRE()

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

See Also: FT_FUSE() FT_FRECNO()

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_FGOTOP

FT_FGOTOP()
 Go to the first record in a text file

 Syntax

      FT_FGOTOP() -> NIL

 Arguments

     None

 Returns

     NIL

 Description

     This function moves the record pointer to the first record
     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_FRECNO() FT_FGOBOT()

FT_FGOTO

FT_FGOTO()
 Move record pointer to specific record in a text file

 Syntax

      FT_FGOTO( nLine ) -> NIL

 Arguments

     <nLine> is the record number to go to.

 Returns

     NIL

 Description

     This function moves the record pointer to a specific record
     in the file in the currently selected text file workarea.  If
     the record number requested is greater than the number of records
     in the file, the record pointer will be positioned at the last
     record.

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

 Examples

     // read 5th line of text from file
     FT_FUSE( "FTTEXT.C" )
     FT_FGOTO(5)
     cText := FT_FREADLN()

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

See Also: FT_FRECNO() FT_FGOTOP() FT_FREADLN()

FT_FEOF

FT_FEOF()
 Determine when end of text file is encountered

 Syntax

      FT_FEOF() -> lResult

 Arguments

     None

 Returns

     .T. if an attempt was made to skip past the last record of
     the currently selected text file, otherwise .F.

 Description

     This function is similar to the CLIPPER Eof() function.

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

 Examples

     FT_FUSE( "FTTEXT.C" )

     ? FT_FEOF()        // .F.
     FT_FSKIP()
     ? FT_FEOF()        // .T.

 Source: FTTEXT.C

 Author: Brice de Ganahl and Steve Larsen

See Also: FT_FUSE() FT_FSKIP()

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