Summary
You can copy or move files and folders in external storage.
Copy or move the file or folder defined in parameter 1 to the file or folder in parameter 2.
You can define whether or not to overwrite when the same named file or folder exists in the destination. You can also include subfolders.
To check which models support file copy, refer to the following.
1.5 Supported Features
Format
_FileCopy(Source folder name/file name, Target folder name/file name, Mode1, Mode2)
Parameter 1
Source folder name: Text string, internal device, or data buffer
Parameter 2
Target file name: Text string, internal device, or data buffer
Parameter 3
Mode1: Numeric value (0, 1, or 2)
Value |
Mode |
Description |
---|---|---|
0 |
Do Not Overwrite |
If the same file name exists, the file will not copy. |
1 |
Overwrite |
If the same file name exists, the file is overwritten. |
2 |
Cut |
If the same file name exists, the file is overwritten. After copy is complete, deletes the original file. |
Parameter 4
Mode2: Numeric value (0 or 1)
Value |
Mode |
Description |
---|---|---|
0 |
Copy subfolders |
When parameter 1 is a folder, include subfolders in the copy operation. |
1 |
Do not copy subfolders |
Do not copy subfolders in the copy operation. |
In the copy destination, when there is a file with the same name that is read-only, regardless of the setting in parameter 3 the file is overwritten.
When the attribute of source files is read-only, even if Parameter 3 is set to Cut, the source file is not deleted.
When copying read-only files, the read-only attribute is removed from files generated in the destination folder. However, this attribute is not removed when using the IPC Series or SP5000 Series Open Box. The files remain as read-only.
In the file properties, the copied files use the date when the files were copied. However, when using the IPC Series or SP5000 Series Open Box, the date becomes the same as the copied source file.
Please select for parameters 1 and 2, a file or folder from the root folder of external storage.
USB Storage: "\USB\DATA"
CF Card: "CF\DATA"
SD Card: "SD\DATA"
When using IPC Series or SP5000 Series Open Box, the defined path and actual path are different. Defined root folder portion (for example, "\USB") is replaced by the path (for example: "C:\PROFACE\DATA") defined from the [System Settings], [Display Unit], in the [WinGP Settings] tab's [Destination Folder] area.
For example, defined path "\USB\DATA2" → actual path "C:\PROFACE\DATA\DATA2"
For parameters 1 and 2, the maximum number of characters you can define are 90 single-byte characters, or 45 double-byte characters. When the defined parameter exceeds the maximum number of characters, uses only the text up to the maximum 90 single-byte/45 double-byte characters.
When using the IPC Series or SP5000 Series Open Box, including the [Destination Folder] path, the parameter should be 247 single-byte characters or less.
You can use the wildcard (*) character for parameter 1.
For example, "USB\DATA\*.BIN" (all the BIN files in USB storage's DATA folder)
However, you cannot add the wildcard character to the file extension or with other text, such as "data*".
For parameter 1, if you define a folder or multiple files, and for the Copy Operation you select do not overwrite, copies only files that do not already exist in the destination.
When an error occurs while copying, the copy operation will halt. However, the script will continue with commands after the file copy function.
When running the file copy function, until the file copy process is complete, you cannot transfer or enter offline mode.
When Parameter 3 indicates Cut, and a write error occurs, the source file or folder will not be deleted.
Example expression:
_FileCopy("\USB\DATA\DATA0001.BIN", "\CF\BACKUP\DATA0001.BIN", 0, 0)
In the above example, the GP3000 series unit uses USB storage. From its \DATA folder, the copy function copies the "DATA0001.BIN" file to the CF card's \BACKUP folder, without overwriting.
By using an internal device in parameter 1 or 2, you can indirectly specify the copied file or folder and the destination file or folder.
Defining the file name with an internal device
_FileCopy([w:[INTERNAL]LS0100], [w:[INTERNAL]LS0200], 0, 0)
The above expression reads the values in LS0100 and and LS0200, then copies the file defined in LS0100 to the destination folder defined in LS0200.
Please make sure you store the NULL character at the end of the file or folder name.
For information about data storage order, please refer to the following.
22.10.7 Data Storage Mode
File Copy Status
You can check the file copy status by reading internal device LS9160. When an error occurs while copying, the error code is saved and the copy operation is halted.
Bit 12 to 15 |
Description |
Details |
---|---|---|
0 |
Completed Successfully |
The process completed successfully. |
1 |
Completed Successfully (Overwrite) |
When copying a folder or copying mulitple files, although the process completed successfully, files failed to copy because the Copy Operation was set to Do Not Overwrite. |
2 |
Parameter error |
There is an error in the parameter definition. |
3 |
Reserved |
- |
4 |
No CF/SD card |
The CF/SC Card is not inserted in the display unit, or the CF Card cover is not closed. |
5 |
Read Error |
Reading from external storage failed. The source file or folder does not exist. |
6 |
Write Error |
Writing data to external storage failed or there is not enough free space. Copying a single file with Mode 1 set to Do Not Overwrite, and a file with the same name already exists in the destination. Copying a single file with Parameter 3 (Mode 1) set to Overwrite or Cut, and a read-only file with the same name already exists in the destination. Copying a folder or multiple files, files failed to copy because some files are read-only. SD card is write protected. |
7 |
CF Card Error |
The CF card is invalid, unformatted, or the format is incorrect and cannot be used. |
8 |
Delete Error |
When Mode 1 is Cut, the source file is read-only or unable to delete the source file. SD card is write protected |
9-13 |
Reserved |
- |
14 |
No USB Storage |
There is no USB storage device inserted into the display unit. |
15 |
USB storage error |
USB storage is invalid, unformatted, or the format is incorrect and cannot be used. |