Move file on SD card
This FP instruction moves the file specified by s1_FullFileNameSource to the file specified by s2_FullFileNameDestination.
Input
Source file and directory
Destination file and directory
File transfer format:
Bit 0:
0: Overwrite if file exists
1: Abnormal end if file exists
Bit 1–15: Reserved for the system
If the directory specified by s2_FullFileNameDestination does not exist, error 3 "File/directory name error" occurs.
If there is not enough free capacity, error 9 "SD card full" occurs.
If a directory is specified by s1_FullFileNameSource, all files in this directory are moved to the directory specified by s2_FullFileNameDestination.
Subdirectories are not moved.
Write-protected files which are moved will keep their status.
The free capacity on the SD card must be larger than the files to be moved.
If a file is specified by s1_FullFileNameSource and a directory by s2_FullFileNameDestination, the file is moved to 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 moves the file 'TestString1.csv' from the root directory of the SD card to the directory 'Test'.
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,,'\TestString1.csv',21,2,23,4,);
B(B_VARIN,,'\Test\TestString1.csv',21,3,23,5,);
B(B_VARIN,,0,21,4,23,6,);
B(B_CONTACT,,bStart,3,1,5,3,R);
B(B_CONTACT,,sys_bIsSDMemoryAccessActive,11,1,13,3,N);
B(B_F,FP_SD_MOVE_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_MOVE_FILE('\TestString1.csv', '\Test\TestString1.csv');
END_IF;