Command COPY FILE Foundation
Copies a file to a new file or to an output device.
Syntax
COPY FILE <cSourceFile> TO <cTargetFile>|<cDevice>
Parameters
<cSourceFile>
<cSourceFile> is a character string containing the name of the source file to copy. The file name must contain the file extension as well as the drive and path if they are necessary. <cSourceFile> can be specified as a literal file name or as a character expression in parentheses.
<cTargetFile>
<cTargetFile> is a character string containing the name of the target file into which the source file is copied. The file name must contain the file extension as well as the drive and path if they are necessary. <cTargetFile> can be specified as a literal file name or as a character string in parentheses.
<cDevice>
A device name, such as LPT1, can be specified instead of a file name. The file <cSourceFile> is then output to this device. If a device with the name <cDevice> does not exist, a file with this name is created. <cDevice> can be specified as a literal file name or as a character expression in parentheses.
Description
The file command COPY FILE copies a source file to a new file or sends the contents of the source file to an output device. If the file name does not include the path, the path specified using SET DEFAULT is used as the default path. If the file <cTargetFile> already exists, it is overwritten without warning. If <cTargetFile> is an invalid file name or <cSourceFile> does not exist, a runtime error is generated.
Examples
// The example shows various calls to the command COPY FILE
PROCEDURE Main
LOCAL cSourceFile := "Test.txt"
LOCAL cTargetFile := "Temp.prn"
// call with variables
COPY FILE (cSourceFile) TO (cTargetFile)
COPY FILE Test.txt TO Temp.prn // call with literal file names
COPY FILE Temp.prn TO LPT1 // output to the device LPT1
RETURN
Feedback
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.