User Tools

Site Tools

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

COPY(file,new 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.

Errors Posted:

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


FromFolder  CSTRING(250)

ToFolder    CSTRING(250)

TheFile     STRING(256),STATIC


Record    RECORD

F1         STRING(1)




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


See Also:


copy_copy_a_file_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)