The sample code below should be entered inside the Edit window's Command mode and not inside the File I/O dialog box.
The following code asks for a file name to copy and for a destination directory and file to copy to.
C1=COMMENT/INPUT,Please type a file you want to copy.
,(Include full file path)
C2=COMMENT/INPUT,Please type a destination file name.
,(Include full file path)
V1=FILE/EXISTS,C1.INPUT
IF/V1<>0
COMMENT/OPER,File exists to copy. Copying commencing.
FILE/COPY,C1.INPUT,C2.INPUT,FAIL_IF_DEST_EXISTS
V2=FILE/EXISTS,C2.INPUT
IF/V2==0
COMMENT/OPER,"File doesn't exist at: " + C2.INPUT
,Copy ending.
ROUTINE/END
END_IF/
ELSE/
COMMENT/OPER,File copy successful.
ROUTINE/END
END_ELSE/
END_IF/
COMMENT/OPER,File to copy doesn't exist.
Code Explanation
Much of this code is similar to that explained in "Sample Code for Read Character" or in "Sample Code for Read Line".
Only explanations unique to this example are given here.
C1=COMMENT/INPUT
This line takes the full pathway of the file to copy and places it into
the C1.INPUT
variable.
C2=COMMENT/INPUT
This line takes the full pathway of the destination file and places it
into the C2.INPUT variable.
FILE/COPY,C1.INPUT,C2.INPUT,FAIL_IF_DEST_EXISTS
This line copies the original file to a destination file. This command
takes three parameters.
Parameter 1 is C1.INPUT. This is the full path to the file to copy.
Parameter 2 is C2.INPUT, or the full path to the destination file.
Parameter 3, in this case, aborts the FILE/COPY procedure if it encounters an existing file with the same destination filename. You can set this so that it overwrites existing files of the same name.
Command Mode Commands after Comments
After you insert a PC-DMIS comment, to type additional PC-DMIS commands in Command mode, you must first press Enter twice after the COMMENT command. This tells PC-DMIS that you no longer want to add text to the comment but are ready to add a new command.