Exchange Files |
Exchanges two files on disk
Syntax
Exchange Files [ Select ; Result (error) ; FilePath 1 ; FilePath 2 ;
Allow different Volumes ]
Options
Select entire contents | replaces the entire contents of a field with the result. If not checked the result replaces the currently selected portion of the field |
Result (error) | an error code |
FlePath 1 | the path to the first file |
FilePath 2 | the path to the second file |
Allow different volumes | allows the exchanging of files between different volumes (disks) |
Returned Result
Data type returned
Error code
Result
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
0 | no error | the files were exchanged |
$$-43 | fnfErr | one (or two) of the files not found |
$$-1303 | diffVolErr | the 2 files are on different volumes |
Other errors may be returned.
Originated in
Troi File Plug-in 10.0
Compatibility
FileMaker Pro 17 to FileMaker Pro 21 (2024)
Considerations
You can use the Exchange Files step to quickly replace a file with an updated file.
When the step returns the error code $$-1303, you can use the checkbox Allow Different Volumes.
Example
We assume that in your FileMaker file the following fields are defined:
gErrorCode Global, number
gFilePath1 Global, text
gFilePath2 Global, text
gFilePath1 and gFilePath2 should contain the path to existing files, for example “D:\Logs\Current.TXT” and
“D:\Work\Updated.TXT”. In a script add the following script steps:
Exchange Files [ $ErrorCode ; gFilePath1 ; gFilePath2 ]
Set Field [ gErrorCode ; $ErrorCode // save the error code too ]
This will (quickly) exchange the two files. After this step the file “D:\Logs\Current.TXT” will have the contents of “D:\Work\Updated.TXT” and vice versa.
Example 2
In a script add the following script stept:
Exchange Files [ $ErrorCode ; "Update Disk:NewData.fmp12" ;
"Work Disk:DataDB.fmp12" ; Allow different volumes" ]
This will exchange the two files, even if the files are on two different volumes (disks).
Used in example file
FileManipulation.fmp12
Related script steps
Copy File |
Delete file |
Move File |
Related function
TrFile_ExchangeFiles |
Related topics
Troi File Plug-in online help (overview)