|
|
|
|
- Example of values that can be taken by
- Values returned by the procedure
WLanguage procedure called by fCopyFile WLanguage procedure ("callback") called by fCopyFile for each copied file. This procedure is used to get the path of the file to be copied and the associated destination path. For example, this procedure can be used to filter the files to be copied. This procedure can be a local, global or internal procedure. // Copy the files found in the "C:\MyImages" directory ResCopy = fCopyFile("C:\MyImages\*.*", "D:\MyFiles\", fCopyFile_Callback) Â INTERNAL PROCEDURE fCopyFile_Callback(ToCopy, Destination) // The procedure is called for each file in the directory. // The ToCopy parameter contains the name of the file to be copied // The Destination parameter contains the name of the destination file // In this example, files with extension ".xlsx" are not copied IF fExtractPath(ToCopy, fExtension) = ".xlsx" THEN RESULT fcIgnore ELSE // Display the name of the file being copied in a static control STC_File_InProgress = ToCopy RESULT fcCopy END END
Syntax
<Result> = fCopyFile_Callback(<File to copy> , <Destination file> [, <Change> [, <Procedure pointer>]])
<Result>: Integer constant Copy of the current element: | | fcCopy | Used to continue the copy. | fcIgnore | Used to ignore the copy of a file. | fcStop | Used to stop the copy permanently. |
<File to copy>: Character string Path and name of the file to copy. <Destination file>: Character string Path and name of the destination file. <Change>: Optional integer constant Used to know if there was a directory change. The possible values are: | | flChangeDir | The file is the first one listed in a subdirectory of <File to copy> (this means that the directory has been changed). | flFile | All other cases. | flFirstFile | The file is the first one listed in the directory of <File to copy>. |
<Procedure pointer>: Optional integer Value passed in the <Pointer> of fCopyFile. If <Pointer> is not specified in fCopyFile, <Procedure pointer> is set to 0. Remarks Example of values that can be taken by <Change> The following are the different values that can be taken by <Change> when browsing the files copied by fCopyFile: | | Current file | <Change> |
---|
Dir\File 1 | flFirstFile | Dir\File n | flFile | Dir\SubDir 1\File 1 | flChangeDir | Dir\SubDir 1\File m | flFile | Dir\SubDir 2\File 1 | flChangeDir | Dir\SubDir 2\File x | flFile |
Values returned by the procedure The procedure called by fCopyFile must return one of the following values: | | fcCopy | Used to continue the copy. | fcIgnore | Used to ignore the copy of a file. | fcStop | Used to stop the copy permanently. |
A WLanguage error occurs if the procedure does not return one of these values. Case 1. Full interruption of copy To force the interruption of the copy, the procedure called by fCopyFile must return the fcStop constant. Example: the "CopyProduct" procedure is automatically called by fCopyFile: PROCEDURE CopyProduct(PathSourceFile, PathDestinationFile) ... // Stop requested? Multitask(-1) IF KeyPressed(kpEscape) = True THEN Info("The copy will be stopped") RESULT fcStop END ... RESULT fcCopy If the Esc key is pressed, the procedure called by fCopyFile returns the fcStop constant. In any other case (to continue copying), the procedure called by fCopyFile returns the fcCopy constant. Case 2. Partial interruption of copy To prevent the procedure called by fCopyFile from being run for a given file, this procedure must return the fcIgnore constant. Example: The "FindProduct" procedure is automatically called by fCopyFile: PROCEDURE FindProduct(PathSourceFile, PathDestinationFile) ... // File to ignore IF StringEndsWith(PathSourceFile, "WrongFile.XLS") THEN RESULT fcIgnore END ... RESULT fcCopy To avoid copying the "WrongFile.XLS" file, the procedure returns the fcIgnore constant. The procedure is automatically called for the next copied file, without copying the current file. Business / UI classification: Neutral code
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|