RENAME

RENAME

Changes the name of a specified file

Syntax

      RENAME <cOldFile> TO <cNewFile>

Arguments

<cOldFile> Old filename

<cNewFile> New Filename

Description

This command changes the name of <cOldFile> to <cNewFile>. Both <cOldFile> and <cNewFile> must include a file extension. This command if not affected by the SET PATH TO or SET DEFAULT TO commands; drive and directory designates must be specified if either file is in a directory other then the default drive and directory.

If <cNewFile> id currently open or if it previously exists, this command will not perform the desired operation.

Examples

      RENAME hello.txt TO hello.old

Compliance

Clipper

Files

Library is rtl

Seealso

CURDIR(), ERASE, FILE(), FERASE(), FRENAME()

FRename()

FRENAME()

Renames a file by low-level access

Syntax

      FRENAME( <cOldFile>, <cNewFile> ) --> nSuccess

Arguments

<cOldFile> Old filename to be changed

<cNewFile> New filename

Returns

<nSuccess> If successful, a 0 will be returned otherwise, a -1 will be returned.

Description

This function renames the specified file <cOldFile> to <cNewFile>. A filename and/or directory name may be specified for either parameter. However, if a path is supplied as part of <cNewFile> and this path is different from either the path specified in <cOldFile> or (if none is used) the current drive and directory, the function will not execute successfully.

Neither parameter is subject to the control of the SET PATH TO or SET DEFAULT TO commands. In attempting to locate the file to be renamed, this function will search the default drive and directory or the drive and path specified in <cOldFile>. It will not search directories named by the SET PATH TO and SET DEFAULT TO commands or by the DOS PATH statement.

If the file specified in <cNewFile> exists or the file is open, the function will be unable to rename the file. If the function is unable to complete its operation, it will return a value of -1. If it is able to rename the file, the return value for the function will be 0. A call to FERROR() function will give additional infor- mation about any error found.

Examples

      #include "fileio.ch"
      nResult := FRename( "x.txt", "x1.txt" )
      IF nResult == F_ERROR
         ? "File could not be renamed."
      ENDIF

Compliance

Clipper

Files

Library is rtl

Seealso

ERASE, FERASE(), FERROR(), FILE(), RENAME

COPY FILE

 

COPY FILE

Copies a file.

Syntax

      COPY FILE <cfile> TO <cfile1>

Arguments

<cFile> Filename of source file <cFile1> Filename of target file

Description

This command makes an exact copy of <cFile> and names it <cFile1>. Both files must have the file extension included; the drive and the directory names must also be specified if they are different from the default drive and/or director. <cFile1> also can refer to a OS device (e.g. LPT1). This command does not observe the SET PATH TO or SET DEFAULT TO settings.

Examples

      COPY FILE C:\harbour\tests\adirtest.prg TO C:\temp\adirtest.prg
      COPY FILE C:\harbour\utils\hbdoc\gennf.prg TO LPT1

Compliance

Clipper

Seealso

ERASE, RENAME, FRENAME(), FERASE()

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

 

C5 Commands

 ?|??            Display one or more values to the console
 @...BOX         Draw a box on the screen
 @...CLEAR       Clear a rectangular region of the screen
 @...GET         Create a new Get object and display it
 @...PROMPT      Paint a menu item and define a message
 @...SAY         Display data at a specified screen or printer row and column
 @...TO          Draw a single- or double-line box
 ACCEPT*         Place keyboard input into a memory variable
 APPEND BLANK    Add a new record to the current database file
 APPEND FROM     Import records from a database (.dbf) file or ASCII text file
 AVERAGE         Average numeric expressions in the current work area
 CALL*           Execute a C or Assembler procedure
 CANCEL*         Terminate program processing
 CLEAR ALL*      Close files and release public and private variables
 CLEAR GETS      Release Get objects from the current GetList array
 CLEAR MEMORY    Release all public and private variables
 CLEAR SCREEN    Clear the screen and return the cursor home
 CLEAR TYPEAHEAD Empty the keyboard buffer
 CLOSE           Close a specific set of files
 COMMIT          Perform a solid-disk write for all active work areas
 CONTINUE        Resume a pending LOCATE
 COPY FILE       Copy a file to a new file or to a device
 COPY STRUCTURE  Copy the current .dbf structure to a new database (.dbf) file
 COPY STRU EXTE  Copy field definitions to a .dbf file
 COPY TO         Export records to a database (.dbf) file or ASCII text file
 COUNT           Tally records to a variable
 CREATE          Create an empty structure extended (.dbf) file
 CREATE FROM     Create a new .dbf file from a structure extended file
 DELETE          Mark records for deletion
 DELETE FILE     Remove a file from disk
 DELETE TAG      Delete a tag
 DIR*            Display a listing of files from a specified path
 DISPLAY         Display records to the console
 EJECT           Advance the printhead to top of form
 ERASE           Remove a file from disk
 FIND*           Search an index for a specified key value
 GO              Move the pointer to the specified identity
 INDEX           Create an index file
 INPUT*          Enter the result of an expression into a variable
 JOIN            Create a new database file by merging from two work areas
 KEYBOARD        Stuff a string into the keyboard buffer
 LABEL FORM      Display labels to the console
 LIST            List records to the console
 LOCATE          Search sequentially for a record matching a condition
 MENU TO         Execute a lightbar menu for defined PROMPTs
 NOTE*           Place a single-line comment in a program file
 PACK            Remove deleted records from a database file
 QUIT            Terminate program processing
 READ            Activate full-screen editing mode using Get objects
 RECALL          Restore records marked for deletion
 REINDEX         Rebuild open indexes in the current work area
 RELEASE         Delete public and private memory variables
 RENAME          Change the name of a file
 REPLACE         Assign new values to field variables
 REPORT FORM     Display a report to the console
 RESTORE         Retrieve memory variables from a memory (.mem) file
 RESTORE SCREEN* Display a saved screen
 RUN             Execute a DOS command or program
 SAVE            Save variables to a memory (.mem) file
 SAVE SCREEN*    Save the current screen to a buffer or variable
 SEEK            Search an order for a specified key value
 SELECT          Change the current work area
 SET ALTERNATE   Echo console output to a text file
 SET BELL        Toggle sounding of the bell during full-screen operations
 SET CENTURY     Modify the date format to include or omit century digits
 SET COLOR*      Define screen colors
 SET CONFIRM     Toggle required exit key to terminate GETs
 SET CONSOLE     Toggle console display to the screen
 SET CURSOR      Toggle the screen cursor on or off
 SET DATE        Set the date format for input and display
 SET DECIMALS    Set the number of decimal places to be displayed
 SET DEFAULT     Set the CA-Clipper default drive and directory
 SET DELETED     Toggle filtering of deleted records
 SET DELIMITERS  Toggle or define GET delimiters
 SET DESCENDING  Change the descending flag of the controlling order
 SET DEVICE      Direct @...SAYs to the screen or printer
 SET EPOCH       Control the interpretation of dates with no century digits
 SET ESCAPE      Toggle Esc as a READ exit key
 SET EXACT*      Toggle exact matches for character strings
 SET EXCLUSIVE*  Establish shared or exclusive USE of database files
 SET FILTER      Hide records not meeting a condition
 SET FIXED       Toggle fixing of the number of decimal digits displayed
 SET FORMAT*     Activate a format when READ is executed
 SET FUNCTION    Assign a character string to a function key
 SET INDEX       Open one or more order bags in the current work area
 SET INTENSITY   Toggle enhanced display of GETs and PROMPTs
 SET KEY         Assign a procedure invocation to a key
 SET MARGIN      Set the page offset for all printed output
 SET MEMOBLOCK   Change the block size for memo files
 SET MESSAGE     Set the @...PROMPT message line row
 SET OPTIMIZE    Change the setting that optimizes using open orders
 SET ORDER       Select the controlling order
 SET PATH        Specify the CA-Clipper search path for opening files
 SET PRINTER     Toggle echo of output to printer or set the print destination
 SET PROCEDURE*  Compile procedures and functions into the current object file
 SET RELATION    Relate two work areas by a key value or record number
 SET SCOPE       Change the boundaries for scoping keys in controlling order
 SET SCOPEBOTTOM Change bottom boundary for scoping keys in controlling order
 SET SCOPETOP    Change top boundary for scoping keys in controlling order
 SET SCOREBOARD  Toggle the message display from READ or MEMOEDIT()
 SET SOFTSEEK    Toggle relative seeking
 SET TYPEAHEAD   Set the size of the keyboard buffer
 SET UNIQUE*     Toggle inclusion of non-unique keys into an index
 SET WRAP*       Toggle wrapping of the highlight in menus
 SKIP            Move the record pointer to a new position
 SORT            Copy to a database (.dbf) file in sorted order
 STORE*          Assign a value to one or more variables
 SUM             Sum numeric expressions and assign results to variables
 TEXT*           Display a literal block of text
 TOTAL           Summarize records by key value to a database (.dbf) file
 TYPE            Display the contents of a text file
 UNLOCK          Release file/record locks set by the current user
 UPDATE          Update current database file from another database file
 USE             Open an existing database (.dbf) and its associated files
 WAIT*           Suspend program processing until a key is pressed
 ZAP             Remove all records from the current database file

 

C5 File Management

C5 File Management Commands and Functions

High Level :

ADIR()* :

Fill a series of arrays with directory information

ADIR( [ <cFilespec> ],
    [ <aFilenames> ],
    [ <aSizes> ],
    [ <aDates> ],
    [ <aTimes> ],
    [ <aAttributes> ] ) --> nFiles

CLOSE :

Close a specific set of files

CLOSE [ <idAlias> | ALL | ALTERNATE | DATABASES | FORMAT |INDEXES ]

COPY FILE :

Copy a file to a new file

COPY FILE <xcSourceFile> TO <xcTargetFile> | <xcDevice>

CURDIR() :

Return the current DOS directory

CURDIR( [ <cDrivespec> ] ) --> cDirectory

DELETE FILE :

Remove a file from disk

DELETE FILE | ERASE <xcFile>

DIR* :

Display a listing of files from a specified path

DIR [ <xcFileSpec> ]

        DIRCHANGE() :

      Change the current DOS directory

       DIRCHANGE(<cDir>) --> nSuccess

DIRECTORY() :

Create an array of directory and file information

DIRECTORY( <cDirSpec>, [ <cAttributes> ] ) --> aDirectory

 DIRMAKE()

         Create a directory

        DIRMAKE(<cNewDir>) --> nSuccess

          DIRREMOVE() :

     Remove a directory

       DIRREMOVE(<cDirName>) --> nSuccess

          DISKCHANGE() :

       Change the current DOS disk drive

        DISKCHANGE(<cDrive>) --> lSuccess

          DISKNAME() :

                  Return the current DOS drive

        DISKNAME() --> cDrive

DISKSPACE() :

Return the space available on a specified disk

DISKSPACE( [ <nDrive> ] ) --> nBytes

ERASE :

Remove a file from disk

ERASE | DELETE FILE <xcFile>

FILE() :

Determine if files exist in the default directory or path

FILE( <cFilespec> ) --> lExists

RENAME :

Change the name of a file

RENAME <xcOldFile> TO <xcNewFile>

SET ALTERNATE :

Echo console output to a text file

SET ALTERNATE TO [ <xcFile> [ADDITIVE]]
SET ALTERNATE on | OFF | <xlToggle>

SET DEFAULT :

Set the CA-Clipper default drive and directory

SET DEFAULT TO [ <xcPathspec> ]

SET PATH :

Specify the CA-Clipper search path for opening files

SET PATH TO [ <xcPathspec list> ]

TYPE :

Display the contents of a text file

TYPE <xcFile> [TO PRINTER] [TO FILE <xcOutFile> ]

Low-level :

FCLOSE() :

Close an open binary file and write DOS buffers to disk

FCLOSE( <nHandle> ) --> lError

FCREATE() :

Create and/or truncate a binary file to zero length

FCREATE( <cFile>, [ <nAttribute> ] ) --> nHandle

FERASE() :

Delete a file from disk

FERASE( <cFile> ) --> nSuccess

FERROR() :

Test for errors after a binary file operation

FERROR() --> nErrorCode

FOPEN() :

Open a binary file

FOPEN( <cFile>, [ <nMode> ] ) --> nHandle

FREAD() :

Read characters from a binary file into a buffer variable

FREAD( <nHandle>, @<cBufferVar>, <nBytes> ) --> nBytes

FREADSTR() :

Read characters from a binary file

FREADSTR( <nHandle>, <nBytes> ) --> cString

          FRENAME() :

Change the name of a file

       FRENAME( <cOldFile>, <cNewFile> ) --> nSuccess

FSEEK() :

Set a binary file pointer to a new position

FSEEK( <nHandle>, <nOffset>, [ <nOrigin> ] ) --> nPosition

FWRITE() :

Write to an open binary file

FWRITE( <nHandle>, <cBuffer>, [ <nBytes> ] )
    --> nBytesWritten

HEADER() :

Return the current database file header length

HEADER() --> nBytes