WCSubscribe
(VTScada-Layer function. Must be called with a leading backslash.)
Description: | Working Copy Subscribe. After this function has been called, any configuration change will result in the specified callback subroutine being called. |
Returns: | Nothing |
Usage: | Script Only. |
Function Groups: | Basic Module, Variable |
Related to: | ReadConfiguration | ModifyConfiguration |
Format: | \WCSubscribe(SubscriberObj[, CallbackModuleName]) |
Parameters: |
SubscriberObj |
A required object, in which the callback module will be called. Often, Self(). |
CallbackModuleName |
An optional text value which is the name of the callback object to be launched into the subscriber object. If invalid or not provided, there must be a submodule in the code, named Notify(), which will be used by WCSubscribe. |
Comments: |
This function is commonly used in conjunction with ReadConfiguration(). The callback() will be notified when a particular file has changed and will trigger another module to call ReadConfiguration() to read the changes from that file. "ChangedFiles" contains absolute file paths. |
Example:
Init [ If 1 Main; [ \WCSubscribe(Self(), "ChangeNotification"); ConfigChanged = 1 { Cause initial read of files }; ] ] Main [ If ConfigChanged; [ ConfigChanged = 0; \ReadConfiguration("ConfigReader"); ] ] < {============================ \ChangeNotification ========================} {=========================================================================} ChangeNotification ( ChangedFiles { Dictionary of changes files }; ) Main [ If 1; [ IfThen(ChangedFiles["MyConfigFile.txt"], ConfigChanged = 1; ); Return(Invalid); ] ] >