Executes an operating system file copy command
from within ABL.
Syntax
OS-COPY
{ source-filename | VALUE ( expression ) }
{ target-filename | VALUE ( expression ) }
|
-
source-filename
- The name of the original file. If you specify a directory, OS-COPY generates
an error. The filename can contain Unicode characters. See OpenEdge
Development: Internationalizing Applications for more information
about Unicode.
- VALUE ( expression )
- An expression that returns the name of the original file. Expression can
contain constants, field names, and variable names. The filename
can contain Unicode characters.
- target-filename
- The name of the new file or directory. If you specify a directory, OS-COPY
gives the target file the same name as the source file. The filename
can contain Unicode characters.
- VALUE ( expression )
- An expression that returns the name of the new file or directory. expression can
contain constants, field names, and variable names. The filename
can contain Unicode characters.
Example
This
procedure opens a dialog box that prompts the user to choose a file
to copy. It then prompts for a name for the copy. Finally, the procedure
uses the OS-COPY statement to copy the file.
r-os-cop.p
DEFINE VARIABLE sourcefilename AS CHARACTER NO-UNDO.
DEFINE VARIABLE copyfilename AS CHARACTER NO-UNDO FORMAT "x(20)"
VIEW-AS FILL-IN.
DEFINE VARIABLE OKpressed AS LOGICAL NO-UNDO INITIAL TRUE.
Main:
REPEAT:
SYSTEM-DIALOG GET-FILE sourcefilename
TITLE "Choose File to Copy"
MUST-EXIST
USE-FILENAME
UPDATE OKpressed.
IF OKpressed = FALSE THEN
LEAVE Main.
UPDATE copyfilename WITH FRAME copyframe.
OS-COPY VALUE(sourcefilename) VALUE(copyfilename).
END.
|
Notes
- The
filenames must conform to the naming conventions of the underlying
operating system.
- If target-file specifies an existing file, OS-COPY
overwrites the existing file.
- If target-file has the same name as source-file,
the copy fails, but OS-ERROR is not set.
- If the copy terminates abnormally, the AVM deletes the partial target-file.
- Enclose filenames that refer to physical devices in double quotes
(" ").
- Although an error can occur during execution of this statement,
the statement does not generate an error message, raise an error
condition, or affect the program's flow in any way. Check for an
execution error by using the OS-ERROR function and evaluating the return.