Writes a string to a file


     STRFILE(<cCharacterstring>, <cFile>, [<lOverwrite>],
        [<nOffset>], [<lCutOff>]) --> nRecordedByte


     <cCharacterstring>  Designates the character string to write to a

     <cFile>  Designates a file name.  Drive and path designations are
     permitted, but no wildcards.

     <lOverwrite>  If not designated or designated as .F., determines
     whether or not a new file is created.  When .T., it writes to an
     existing file.  The default is create new file (.F.).

     <nOffset>  Designates an offset within the file from which the
     <cCharacterstring> string is to be written.  The default is End of file.

     <lCutOff>  When this optional parameter is designated as .T., the
     function truncates the file if data written ends before the last file
     byte.  The default is no cut off (.F.).


     STRFILE() returns the actual number of bytes written.


     This function provides another capability besides writing the contents
     of a string to a file.  In contrast to the Clipper Fxxxx() functions,
     only one function call is necessary to write data to a file.  However,
     it can result in some speed disadvantages, since files acted on by
     STRFILE() cannot be held open.

     If the target file is unavailable, the STRFILE() function always creates


     .  The attribute to create a new file, can be designated with the
        SETFCREATE() function.

     .  As recommended with the share mode, reads and writes from
        other network programs should be locked out with SETSHARE() for this
        period of time.

     .  This function acknowledges the setting for CSETSAFETY().


     .  Add to the end of a file:

        ? STRFILE("ABCDEFGH", "TEST.TXT", .T.)             // Result: 8

     .  A file with drive and path designations, result: 10:

        ? STRFILE("0123456789", "C:\TEXT\TEST.TXT", .T.)

     .  Data in an existing file is overwritten from position 20 with
        a designated string:

        ? STRFILE("NANTUCKET", "TEST.TXT", .T., 20)        // Result: 9

     .  A 5-character string is written starting at position 10 in an
        existing file 20-characters long.  Since the final parameter is
        specified as .T. once, and specified as .F. once, you see different

        ? STRFILE(REPLICATE("X", 20), "TEST.TXT")
        ? STRFILE("AAAAA", "TEST.TXT", .T., 10, .T  // "XXXXXXXXXXAAAAA"



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.