|Navigation: Language Reference > 13 - Built-in Functions >====== COPY (copy a file) ======|
|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.
|02||File Not Found|
|03||Path Not Found|
|52||File Already Open|
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