|
|
|
|
- Special cases
- WLanguage procedure
fWatchFile (Function) In french: fSurveilleFichier
Warning
From version 2024, fTrackFile is kept for backward compatibility. This function has been replaced with fWatchFile.
Starts watching a file. In case of file modification, a specific procedure is run in a thread.
sFileName is string = "C:\Temp\MyDir\MyFile.extension"
IF fWatchFile(sFileName, fWatchFile_Callback, ...
fwCreateFile + fwModifyFile + fwDeleteFile + ...
fwRename) THEN
Info("The " + sFileName + " file will be watched.")
ELSE
Info("The " + sFileName + " file will not be watched.")
END
INTERNAL PROCEDURE fWatchFile_Callback(sFullName, sFileName, nAction, sOldFileName)
sActionDesignation is string
SWITCH nAction
CASE fwCreateFile: sActionDesignation = "Creating files"
CASE fwDeleteFile: sActionDesignation = "Deleting files"
CASE fwModifyFile: sActionDesignation = "Modifying files"
CASE fwRename: sActionDesignation = "Renaming files"
END
TableAddLine(TABLE_MODIFICATIONS, sFullName, sFileName, ...
sActionDesignation, sOldFileName)
END
Syntax
<Result> = fWatchFile(<File to watch> , <WLanguage procedure> [, <Changes to notify>])
<Result>: Boolean - True if file watching is enabled,
- False otherwise. To get more details on the error, use ErrorInfo.
<File to watch>: Character string Full name of the file to be watched. <WLanguage procedure>: Procedure name Name of the WLanguage procedure ("callback") called when a change is made to the specified file. <Changes to notify>: Optional Integer constant (or combination of constants) Changes made to the watched file and for which the procedure is to be executed: | | fwAll | All actions are watched. Corresponds to fwCreateFile + fwModifyFile + fwRename + fwDeleteFile.New in version 2024Before version 29 Update 2, this constant was named ftAll. | fwCreateFile | Creation of <File to watch>.New in version 2024Before version 29 Update 2, this constant was named ftCreateFile. | fwDeleteFile | Deletion of <File to watch>.New in version 2024Before version 29 Update 2, this constant was named ftDeleteFile. | fwModifyFile | Modification of <File to watch>.New in version 2024Before version 29 Update 2, this constant was named ftModifyFile. | fwRename | Renaming of <File to watch>.New in version 2024Before version 29 Update 2, this constant was named ftRename. |
Remarks Special cases - To stop watching the file, use fWatchStop and fWatchStopAll.
- To watch changes made to the contents of a directory, use fWatchDirectory.
- Limitations:
- Only 5 files can be watched at the same time.
- It is not possible to watch a file located at the root of a disk (for performance reasons).
WLanguage procedure The WLanguage procedure is run in a WLanguage thread. Caution: The following processes cannot be run in threads: - opening windows with WLanguage functions such as Open, Use, Close, etc. A specific management mode must be implemented if some windows must be handled in threads (rare case). For more details, see Opening a window in a secondary thread.
- managing events.
- managing timers.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|