[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 RENAME
 Change the name of a file
------------------------------------------------------------------------------
 Syntax

     RENAME <xcOldFile> TO <xcNewFile>

 Arguments

     <xcOldFile> is the name of the file to be renamed including an
     extension, and optionally is preceded by a drive and/or path designator.
     <xcOldFile> can be a literal string or a character expression enclosed
     in parentheses.

     TO <xcNewFile> specifies the new file name including extension and
     optionally prefaced by a drive and/or path designator.  <xcNewFile> can
     be a literal string or a character expression enclosed in parentheses.

 Description

     RENAME is a file command that changes the name of a specified file to a
     new name.  If the source directory is different from the target
     directory, the file moves to the new directory.  RENAME does not use SET
     DEFAULT and SET PATH to locate <xcOldFile>.  Instead, the <xcOldFile> is
     renamed only if it is located in the current DOS directory or in the
     specified path.

     In the instance that either <xcNewFile> exists or is currently open,
     RENAME does nothing.  To trap this condition as an error, use the FILE()
     function before executing the command.  See the example.

     Warning!  Files must be CLOSEd before renaming.  Attempting to
     rename an open file will produce unpredictable results.  When a database
     file is RENAMEd, remember that any associated memo (.dbt) file must also
     be RENAMEd.  Failure to do so may compromise the integrity of your
     program.

 Examples

     .  This example renames a file, checking for the existence of the
        target file before beginning the RENAME operation:

        xcOldFile := "OldFile.txt"
        xcNewFile := "NewFile.txt"
        IF !FILE(xcNewFile)
           RENAME (xcOldFile) TO (xcNewFile)
           ELSE
        ? "File already exists"
        ENDIF

 Files   Library is CLIPPER.LIB.


See Also: COPY FILE CURDIR() ERASE FILE() FERASE() FRENAME()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson