C5_RENAME

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

 

Advertisements

2 responses to “C5_RENAME

  1. Pingback: C5 File Management | Viva Clipper !

  2. Pingback: C5 Commands | Viva Clipper !

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.