Copy file or directory on SD card
This FP instruction copies the file on the SD card specified by s1_FullFileNameSource to the file specified by s2_FullFileNameDestination according to the parameters specified by s3_Format.
Input
Source file and directory
Destination file and directory
File handling and format:
Bit 0:
0: Overwrite if file exists
1: Abnormal end if file exists
Bit 1–15: Reserved for the system
Please also refer to precautions for SD card access.
The SD memory access active flag (sys_bIsSDMemoryAccessActive) turns to TRUE after the trigger EN of the SD card instruction has turned to TRUE and remains TRUE until execution has completed. During this time, other SD card instructions cannot be executed.
If a directory is specified for s1_FullFileNameSource and a file for s2_FullFileNameDestination, error 3 "File/directory name error" occurs.
If a directory is specified by s1_FullFileNameSource, all files in this directory are copied into the directory specified by s2_FullFileNameDestination. Subdirectories are not copied.
Write-protected files will not be overwritten.
If s1_FullFileNameSource and s2_FullFileNameDestination are identical, an error occurs regardless of the value of s3_Format.
If a file is specified by s1_FullFileNameSource and a directory by s2_FullFileNameDestination, the file is copied into the directory.
All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.
VAR
bStart: BOOL:=FALSE;
(*activates the instruction*)
END_VAR
When the variable bStart changes from FALSE to TRUE and the system variable sys_bIsSDMemoryAccessActive is not TRUE, the function is carried out. It copies the file 'TestString1.csv' in the directory 'Test' into the file 'TestString2.csv' in the same directory.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 6 ;
NETWORK_BODY
B(B_VARIN,,0,21,4,23,6,);
B(B_CONTACT,,bStart,3,1,5,3,R);
B(B_VARIN,,'\Test\TestString1.csv',21,2,23,4,);
B(B_VARIN,,'\Test\TestString2.csv',21,3,23,5,);
B(B_CONTACT,,sys_bIsSDMemoryAccessActive,11,1,13,3,N);
B(B_F,FP_SD_COPY_FILE!,,23,0,37,6,,?DEN?Ds1_FullFileNameSource?Ds2_FullFileNameDestination?Ds3_Format?AENO);
L(1,2,3,2);
L(5,2,11,2);
L(13,2,23,2);
L(1,0,1,6);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF DF(bStart)AND not sys_bIsSDMemoryAccessActive then
FP_SD_COPY_FILE('\Test\TestString1.csv', '\Test\TestString2.csv');
END_IF;