Exchange Files (script step reference)

Troi File Plug-in for FileMaker Pro

Exchange Files

Exchanges two files on disk

SyntaxScript step badge

Exchange Files [ Select ; Result (error) ; FilePath 1 ; FilePath 2 ;
Allow different Volumes ]

Options

Select entire contentsreplaces 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 1the path to the first file
FilePath 2the path to the second file
Allow different volumesallows 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:

0no errorthe files were exchanged
$$-43fnfErrone (or two) of the files not found
$$-1303diffVolErrthe 2 files are on different volumes

Other errors may be returned.

Originated in

Troi File Plug-in 10.0

Compatibility

FileMaker Pro 16 to 17

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).

Related script stepsScript step badge

Copy File
Delete File
Move File

Related functionFunction badge

TrFile_ExchangeFiles

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 13 to 17 –> Exchange Files (filep7317) 2018-0515 14:39:56