User Tools

Site Tools


copy_copy_a_file_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== COPY (copy a file) ====== Previous pageReturn to chapter overviewNext page

COPY(file,new file)

blk2blue.jpg

COPY Duplicates a file.
file The label of a FILE structure, or a string constant or variable containing the file specification of the file to copy.
new file A string constant or variable containing a file specification. If the file specification does not contain a drive and path, the current drive and directory are assumed. If only the path is specified, the filename and extension of the original file are used for the new file.

The COPY statement duplicates a FILE and enters the specification for the new file in the operating system's directory listing. The file to copy must be closed, or the “File Already Open” error is posted. If the file specification of the new file is identical to the original file, the COPY statement is ignored.

Since some file drivers use multiple physical disk files for one logical FILE structure, the default filename and extension assumptions are dependent on the file driver. If any error is posted, the file is not copied.

Errors Posted:

02 File Not Found
03 Path Not Found
05 Access Denied
52 File Already Open

Example:

FromFolder  CSTRING(250)

ToFolder    CSTRING(250)

TheFile     STRING(256),STATIC

SomeFile FILE,DRIVER('DOS'),NAME(TheFile)

Record    RECORD

F1         STRING(1)

         END

        END

CODE

TheFile = 'Names.DAT'

COPY(TheFile,'A:\')                       !Copy file to floppy

COPY('C:\AUTOEXEC.BAT','A:\AUTOEXEC.BAT') !Copy file to floppy

FromFolder = 'z:\my folder\file1.tps'

ToFolder = 'z:\backup area' !Use double quotes to handle folders with spaces

COPY(FromFolder,ToFolder)

See Also:

CLOSE

copy_copy_a_file_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1