|
|
|
|
- Example of values that can be taken by
- Values returned by the procedure
WLanguage procedure called by fCopyDir WLanguage procedure ("callback") called by fCopyDir for each copied file. This procedure is used to handle the current file. // Copy a directory Res = fCopyDir("C:\Directory\MyFiles", "D:\Documents\FileCopy", FilterFile) PROCEDURE FilterFile(sSourcePath, sDestinationPath, flChange, nCustomParameter) Â // Don't copy the temporary files IF fExtractPath(sSourcePath, fExtension) ~= ".tmp" RESULT fcIgnore ELSE RESULT fcCopy END Syntax
<Result> = fCopyDir_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 fCopyDir. If <Pointer> is not specified in fCopyDir, <Procedure pointer> is set to 0.To get the value of <Procedure pointer>, its value must be assigned to the value of <Pointer> in the procedure with Transfer. 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 fCopyDir: | | 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 fCopyDir 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 fCopyDir must return the fcStop constant. Example: the "CopyProduct" procedure is automatically called by fCopyDir: 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 fCopyDir returns the fcStop constant. In any other case (to continue copying), the procedure called by fCopyDir 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 fCopyDir: 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.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|